Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Xrm.Page.data Property is NULL when used inside Webresource embedded on a Form

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a WebResource with html mark-up that draws a html button with an onclick event.  The onclick event calls a javascript function that tries to reference the data property on Xrm.Page.  The html webresource is embedded on a Form in a custom entity.

When I click the html button and debug the script I can see that Xrm.Page.data is NULL. 

I tried calling this same javascript function in the OnLoad event of Form. In this case the Xrm.Page.data property is not null.

 Should i expect the  Xrm.Page.data property to be NULL when embedded in a webreource on a form and populated when used in OnLoad event of the form?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm.Page.data Property is NULL when used inside Webresource embedded on a Form

    This is the information I needed. Thanks

  • Verified answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Xrm.Page.data Property is NULL when used inside Webresource embedded on a Form

    Web resources are not in the same level as the actual CRM page.

    You can access the data class of Xrm.Page using parent.Xrm.Page.data or you can redefine Xrm inside you own web resource:

    var Xrm = parent.Xrm;

    After that you should be able to use: Xrm.Page.data...

    Hope this helps.

  • Verified answer
    Michel van den Brink Profile Picture
    Michel van den Brink 4,697 on at
    RE: Xrm.Page.data Property is NULL when used inside Webresource embedded on a Form

    Hello,

    When you embed a WebResource into an Entity Form, you need to go up one level, to reach the form first.

    Try:

    var entityDataInForm = parent.Xrm.Page;


      

    Note: this only works if you include the WebResource into the Entity Form with the WebResource component, it does not work with an iFrame.

      

    Hope this helps you. If you have any other questions, please let me know!

    If you found my answer helpful, please help the community by marking it as verified :-)

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,904 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,605 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans