Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

How do I get the parent id in Unified Interface mode?

Posted on by 95

In a legacy web environment, I previously used javascript to get the parent ID from the querystring, i.e.

            var queryString = window.parent.Xrm.Page.context.getQueryStringParameters();
            parentRecordId = queryString._CreateFromId;

How do I achieve the same in Unified Interface mode?

Thanks in advance.

  • Chevva Profile Picture
    Chevva 95 on at
    RE: How do I get the parent id in Unified Interface mode?

    Hi,

    It appears that for webresources, the following still works in UI mode:

               var queryString = window.parent.Xrm.Page.context.getQueryStringParameters();

               parentRecordId = queryString.parentrecordid;

    This article docs.microsoft.com/.../important-changes-coming states that "Although Xrm.Page is deprecated, 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."

    So, it may be (many?) years before Xrm.Page is truly deprecated for webresources. If, as MS state, "...this is the only way to access the form context" I assume they will come up with an alternative...

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How do I get the parent id in Unified Interface mode?

    Hello,

    If it's located in HTML webresource you can use 2 approaches:

    1. Pass it through URL of the webresource (build it on the fly passing Id as a part of URL using data parameter).

    2. Use window.parent.Xrm.Page.getAttribute("fieldthatreferencesparententity).getValue() in your HTML webresource.

  • Chevva Profile Picture
    Chevva 95 on at
    RE: How do I get the parent id in Unified Interface mode?

    The problem is that the javascript that attempts to get the parentid is located in an HTML webresource.

  • Suggested answer
    Gilmeyer Profile Picture
    Gilmeyer on at
    RE: How do I get the parent id in Unified Interface mode?

    Hi ,

    Xrm.Page.context.getQueryStringParameters method is deprecated in Dynamics CRM365 v9. Please use formContext.data.attributes instead.

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

    Hope it helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans