ENGINEERED CODE BLOG

Where’s That Dynamics 365 Portals Code? – Part 2

In my previous blog post, I talked about the overall page structure for a Dynamics 365 Portals page, and the main elements included in the rendered page, including the Header, Footer, and the Page Content. In this post, I get into the details about where code might be within the Page Content.

Perhaps in the Page Template?

So if the code you’re looking for isn’t in the Header or Footer Web Templates (or other Web Templates referenced by them), most likely the code is coming from something more page-specific. One place to look is the Web Template that is references by the Page Template.

The Web Template referenced in the Page Template defines how the Page Content is displayed. It’s possible that the code you’re looking for was included as part of this Web Template (or in a Web Template it includes). It’s also typically the job of this Web Template to include the Copy attribute of the Web Page, which leads me to the more likely locations of the custom code.

Copy Attribute, Summary Attribute, Custom JavaScript and Custom CSS

Each Web Page record has four fields that are generally used for code: Copy, Summary, Custom JavaScript, and Custom CSS.

It is the responsibility of whomever implements the Web Template used by the Page Template to include the Copy and Summary attributes on a page (typically the Summary field is used on parent pages to show as introductory text along with a link to the child page). If the Page Template doesn’t include it, whatever you put in those fields won’t appear on the page.

This is not the case with Custom JavaScript and Custom CSS – these appear automatically as part of the markup, as long as the Use Website Header and Footer attribute is checked on the Page Template. Code included in the Custom CSS attribute will automatically be wrapped in a <style> tag and placed before the closing <head> tag in the markup, and the Custom JavaScript will be automatically wrapped in a <script> tag and appear near the closing <body> tag.

If the Page Template does not use the website headers and footers, these fields will not automatically appear in the markup – they’d have to be included manually in the Web Template used by the Page Template.

Also note that these fields all support Liquid code, so it’s completely possible to use the include Liquid tag to reference other code.

Finally, a note about the multilingual data model. When introduced in v8, the multilingual capabilities added the concept of root Web Pages, which are essentially container objects for individual Web Pages for each language enabled for the portal. These root web pages have Copy, Summary, Custom JavaScript and Custom CSS attributes, but unless you explicitly reference them, they will not be automatically included anywhere. In my opinion, they should remove the Custom JavaScript and Custom CSS fields from the root web page form, as it just leads to confusion. All of your code should be placed in the attributes of the localized web page record.

So, Where is the Code?

So far, we’ve looked at the Header and Footer Web Templates, the Web Template referenced in the Page Template, and the Copy, Summary, Custom JavaScript and Custom CSS fields on the Web Page.

Next, we’ll go further down the rabbit hole and look at Entity Forms, Entity Lists, and a few other places.

One response to “Where’s That Dynamics 365 Portals Code? – Part 2”

  1. […] my previous blog post, I talked about looking at the page-specific attributes like Copy, Summary, Custom JavaScript and […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact

Engineered Code is a web application development firm and Microsoft Partner specializing in web portals backed by Dynamics 365. Led by a professional engineer, our team of technology experts are based in Regina, Saskatchewan, Canada.