web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Access Form data in HTML Webresources

(0) ShareShare
ReportReport
Posted on by 115

Hi Guys,

I have a query regarding HTML webresource.

For CRM v8.2, We have created a HTML webresource and added the same in the form. This webresource read a field data from the Current form and filter data accordingly in HTML. For reading data we are using below code

window.parent.Xrm.Page.getAttribute("fieldname").getValue();

As per my knowledge CRM v9.0 has deprecated Xrm.page.getAttribute. So can any one whats the alternative way to read data from the current form in HTML webresource.

Regards,
Sourav

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Access Form data in HTML Webresources

    Hi Sourav,

    Please find below code -

        var formContext = executionContext.getFormContext(); // get formContext
    
        // use formContext instead of Xrm.Page  
        var firstName = formContext.getAttribute("firstname").getValue(); 
        var lastName = formContext.getAttribute("lastname").getValue();


    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-form-context

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/attributes/getvalue

    Hope this helps.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Access Form data in HTML Webresources

    Hi Sourav ,

    Here is the sample how to pass execution context to the javascript web resource.

    docs.microsoft.com/.../clientapi-execution-context

  • Sourav0147 Profile Picture
    115 on at
    RE: Access Form data in HTML Webresources

    The example above are for Javascript webresource function and i am looking for HTML Webresourse so i believe i will not have an access to FormContext or executionContext.

  • Suggested answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: Access Form data in HTML Webresources

    Hi Sourav,

    Xrm.Page has been replaced by ExecutionContext.getFormContext

    Can see this for more details:

    https://community.dynamics.com/crm/b/exploringdynamics365/archive/2017/08/07/new-in-v9-what-s-that-with-xrm-page-being-deprecated

     

    Hope it helps.

     

    If you find the answer useful, please mark it as verified

     

    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

     

     

     

     

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Access Form data in HTML Webresources

    Hi,

    refer below post on how to get context outside a form.

    msdn.microsoft.com/.../gg328541.aspx

  • Sourav0147 Profile Picture
    115 on at
    RE: Access Form data in HTML Webresources

    How can we get ExecutionContext in HTML Web resource ??

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Access Form data in HTML Webresources

    Why you are passing html web resource . You can create another js web resource and add reference js web resource to your html. I mean seperate js and HTML.

  • Sourav0147 Profile Picture
    115 on at
    RE: Access Form data in HTML Webresources

    Yes  i have created a HTML webresource and a JS web resource. Added this JS web resources in Script tag of HTML. Since JS is added in the HTML webresource, i believe i cant get executionContext object.

    @Fun Wei Jie: Thanks for the response but i am looking for CRM v9 version.

  • Suggested answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: Access Form data in HTML Webresources

    Hi Sourav,

    Please take a look below article, if not gone through already. Hope it helps.

    http://dynamicscrmcoe.com/passing-data-crm-form-custom-html-web-resource/

    If you find the answer useful, please mark it as verified.

    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

     

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Access Form data in HTML Webresources

    Ho Sourav,

    You are correct , executionContext is only for form and you will not get the executionContext in your HTML web resource , so there is no way to use new formContext in html web resource or we can say Dynamics 365 does not support formcontext inside HTML webresource.

    Microsoft says that Xrm.Page will be deprecated but not yet so you can use Xrm.Page in your HTML web resource until official announcement. You can refer below msdn reference -

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-form-context

    webres.JPG

    There is no issue  as Microsoft  never said not to use  Xrm.Page in HTML web resource rather Microsoft says that you can use. You can refer below msdn reference 

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webpage-html-web-resources

    webres.JPG

    So In summary use  Xrm.Page in HTML web resource and there is no alternate solution provided by Microsoft till now. You should replace Xrm.Page with formContext those JavaScript function are communicating with the OOB form itself.

    So thanks to raise the issue in community. Now seems all confusion has gone ;) .

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans