How to use FormContext in Web Resource in Dynamics 365 V9 - Moazam Badane's Blog

Before Dynamics 365 V9 we were able to access elements using Xrm.Page, which has now been deprecated. So now we need a way to access these controls from an HTML web resource.

However, there is also getContentWindow in Client API that helps is to achieve this. 

Let's take a look at how it works.

Create a Web Resource as Below, Add add it to any entity (e.g Lead)


Adding Web Resource to form.


Code snippet for HTML Web Resource


Now we need to pass FormContext to Web resource from Lead Entity.
Create a javascript as below and attach "form_onload" on Load of the form (Make Sure you mention web resource name properly).


Code snippet for JavaScript

Attach the Javascript function on Load of Entity as below.


All Done, Now let's test this.


So this gives us FormContext in WebResource, without having to use Xrm.Page. Feel free to comment on your experiences.


Post a Comment

0 Comments