JavaScript Code Location on Portals 8.2

Microsoft Dynamics 365 Portals v8.2 introduced a new way to implement multilanguage portals.  I outlined how to enable multi-language on portals here.

Essentially, there is now a “parent” web page record as well as a “child” page for the default language and additional content language pages can be added.

pagestructure
Portals 8.2 Web Page Structure

What can be confusing is if you want to add some JavaScript code to the web page and where it should go.

If you navigate to the “parent” web page record, and scroll down and click “Advanced” there will be a section to add JavaScript.

parentpage1

parentpagejs

However, this code will not actually run on your web page, which could cause some confusion and delay when trying to add and edit JavaScript on your web page.  Mainly because in Portals 8.1 and Legacy Adxstudio, that is where the code would go.

doesntwork
JavaScript Code just doesn’t work there anymore.

You will actually need to navigate to *each* content page to add the JavaScript.  This is not necessarily ideal in terms of code management, but the plus side is that some of messaging from the JavaScript might have to be in a seperate language anyway.

navigatetocontentpage

The code in the content page will run.

contentpage

If we navigate to the web page on the portal, we will see the appropriate result (and based on the alert message, know that its the code on the child page that gets run).

coderunning

There are other ways to ensure that your code gets added to the correct spot.  You are able to add JavaScript code via the the front side editor.

frontsideediting

The new update to the XrmToolBox will make it easier to manage this code.  The latest build identifies the particular content pages.  (Along with colour coding!)

xrmtoolbox

Hopefully this information will help as you add JavaScript to your Portal projects!

Cheers
Nick

Nick Doelman is a Microsoft Business Solution MVP and wants to let his blog readers that it is currently the NHL playoffs and that Canada is pretty much shut down until the Stanley Cup is awarded.  Go Sens!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s