Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Xrm.WebApi in a stand alone Web Resource

(0) ShareShare
ReportReport
Posted on by 5

I have a stand alone web resource linked from the site menu in a Model Driven App. It does multiple api calls using parent.Xrm.WebApi and currently works fine. According to Microsoft deprecation notice, https://docs.microsoft.com/en-us/power-platform/important-changes-coming, parent.Xrm will be going away and no longer work for standalone Web Resource. Xrm.WebApi without referencing the parent throws an error "Xrm" is not defined. Can anyone help with a supported way to access Xrm.Utility and Xrm.WebApi from a standalone web resource?

NOTEparent.Xrm will be removed after the removal of the ClientGlobalContext.js.aspx page; dates yet to be announced.

  • Xrm.WebApi in a stand alone Web Resource

    I am using a Web Resource linked from the site menu, not embedded in to a form.  

    "parent.Xrm.* will work if the HTML web resource is loaded in a form container. However, for other places, such as loading an HTML web resource as part of the SiteMap, parent.Xrm.* also won’t work."

    So I am trying to find out if there is a supported way to access Xrm in this scenerio

    Do we have answer for this?

  • Suggested answer
    RE: Xrm.WebApi in a stand alone Web Resource

    Try using opener.Xrm to access the Xrm object in a standalone webresource opened from a form as described here in the parent.Xrm section: docs.microsoft.com/.../important-changes-coming

    "If the getContentWindow method doesn't work, you can use parent.Xrm to get to the Xrm object inside an HTML web resource. If the HTML web resource is opened in a new window, then you should use opener.Xrm instead."  

  • Noorahmad001 Profile Picture
    Noorahmad001 130 on at
    RE: Xrm.WebApi in a stand alone Web Resource

    Did you find any solution for the problem you posted in the community i.e. using xrm in standalone webresource in Dynamics 365

  • Suggested answer
    Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: Xrm.WebApi in a stand alone Web Resource

    Hi DanWa,

    I think you can use the getContentWindow() method. This will work only on Unified Interface.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/getcontentwindow

    https://www.inogic.com/blog/2020/08/how-to-use-xrm-and-formcontext-in-html-webresource-in-dynamics-365-crm/

    Hope this helps.

    Best Regards

    PG

  • Diana Birkelbach Profile Picture
    Diana Birkelbach 140 Most Valuable Professional on at
    RE: Xrm.WebApi in a stand alone Web Resource

    A possibility would be to use PCF (PowerApps Component Framework).

    The PCF could be defined for datasets (so you can bind a PCF to an Entity  which is shown in the home grid).

    Maybe you get even more: the Dataset PCFs could give you even the data that you retrieve now using the Xrm.WebApi (or at least a part of it).

    This would work now.

    In the future, also unbound PCFs will be possible (then you don't need a view to bind the PCF).

    Kind regards,

    Diana

  • DanWa Profile Picture
    DanWa 5 on at
    RE: Xrm.WebApi in a stand alone Web Resource

    I am using a Web Resource linked from the site menu, not embedded in to a form.  

    "parent.Xrm.* will work if the HTML web resource is loaded in a form container. However, for other places, such as loading an HTML web resource as part of the SiteMap, parent.Xrm.* also won’t work."

    So I am trying to find out if there is a supported way to access Xrm in this scenerio

  • Bipin D365 Profile Picture
    Bipin D365 28,959 Super User 2024 Season 1 on at
    RE: Xrm.WebApi in a stand alone Web Resource

    Hi,

    As per docs parent.Xrm.Page will continue to work in case of HTML web resources embedded in forms as this is the only way to access the form context from the HTML web resource.

    docs.microsoft.com/.../important-changes-coming

    Please mark my answer verified if i were helpful

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

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans