Link Web Resource To A Form Using Classic UI In Dynamics CRM

Introduction

In Dynamics 365 CRM, the way to link Web resource to a Form was by using Classic form where we can attach a web resource to form. As an example, in Contact customizations solution for contact main form we see how to link web resource by registering to form load event using classic UI which most of the earlier versions of CRM before Unified interface.

Step 1

Login to the required environment and select required solution [Contact Customizations Solution in this case] as shown in the below figure.

Link Web resource to Form using Classic UI in Dynamics CRM Figure 1

Step 2

After Step 1, select Contact table and navigate to Forms section and at the top of the form using ribbon at the right side click on 3 dots … beside Show dependencies and select Switch to Classic as shown in the below figure.

Link Web resource to Form using Classic UI in Dynamics CRM Figure 2

Step 3

After Step 2,  a new window will open with classic UI interface with contact entity and select Forms and then double click contact Main form and a new popup opens with contact form as shown in the below figure.

Link Web resource to Form using Classic UI in Dynamics CRM Figure 3

Step 4

After Step 3, in case Main form, click on Form Properties and a new popup will appear and under Event List section -> Form Libraries click on Add button as shown in the below figure.

Link Web resource to Form using Classic UI in Dynamics CRM Figure 4

Step 5

After Step 4, a new lookup window popup and search for contact.js web resource and click on Add and as shown in the below figure.

Link Web resource to Form using Classic UI in Dynamics CRM Figure 5

Step 6

After Step 5, you could see contactform webresource under Form Libraries and then under Event Handlers select the following

Control : Form

Event : OnLoad

And click on Add button as shown in the below figure.

Link Web resource to Form using Classic UI in Dynamics CRM Figure 6

Step 7

After Step 6, new Handler properties window will be opened and there provide the following values as inputs

Library: cr5bc_contactform

Function : ContosoVaccination.Scripts.ContactForm.handleOnLoad

and select pass execution context as first parameter check box and then click on Ok button as shown in the below figure

Link Web resource to Form using Classic UI in Dynamics CRM Figure 7

Step 8

After Step 7, click on ok button in Form Properties popup and then click on save and publish as shown in the below figure

Link Web resource to Form using Classic UI in Dynamics CRM Figure 8

Step 9

After Step 8, to test this open any existing or new contact record and can observe in a console window on load - contact form text (contact related web resource will be loaded and we can keep a breakpoint) will be shown as shown in the below figure

Link Web resource to Form using Classic UI in Dynamics CRM Figure 9

Note:

  1. Make sure to publish all customizations and upload JavaScript (js) file.
  2. For other Forms for an entity we can add a web resource in the same way.
  3. Same process is applicable for Save Event as well.
  4. ContosoVaccination.Scripts.ContactForm.handleOnLoad method in Step 7 was taken from contact javascript webresource as shown in the below figure.

Link Web resource to Form using Classic UI in Dynamics CRM Figure 10

Conclusion

In this way, one can easily link/refer to a web resource in CRM Forms in entities easily using Classic UI.