Although this Help article states that with Microsoft Dynamics CRM 2016/Online “You can’t include a web resource in a form header or footer”, you certainly can.
Sadly, form Footer Web Resource no longer display any content (as it did in version 2015). Form header displays content correctly, but adding it will spread the header fields all over the form width.
Unlike header attributes, which can be accessed using Xrm.Page.getControl(“header_name”), the header Web Resource can not be accessed this way as it seem to be invisible to the getControl function.
So how can the header Web Resource ‘Listen’ to form and field events?
Since Web Resource can access the Xrm.Page object via the parent object, it has full access to the form elements and events. The addOnChange function allows the the Web Resource code to register an internal function as an event handler for a form or field event.
The following sample demonstrates HTML Web Resource located in the Account form header area, ‘listening’ to the Account Name attribute change event.
The code is located in the HTML Web Resource:
//register event handler to the account name attribute onChange event
if(parent.Xrm.Page != null)
//do something with the Web Resource content…
alert(“Refreshing Web Resource content…”);