Skip to main content

Notifications

Announcements

No record found.

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

Using Javascript, how does someone check which entity a new record was created from?

Posted on by 65

Hello CRM Community,

If I'm not mistaken, Microsoft has deprecated the getQueryStringParameters() function in the new UCI, and I need help figuring out how to update our method to work with UCI.


BACKGROUND:

From an Entity A form, I am creating a new Entity B record (see Fig. 1 directly below)

Fig 1.

pastedimage1571769013598v1.png

Currently, we're using the following function to check which entity Entity-B was created from, but like I mentioned, this does not work anymore in the new UCI:

var createFrom = Xrm.Page.context.getQueryStringParameters()._CreateFromType;




QUESTION:

After clicking "New" and I'm on a new Entity B form, using the execution context passed via the event handler on a form (see Fig. 2 below), how can I retrieve the ID and Name of the entity from which Entity B was created? (This is a JavaScript web resource function that will be triggered when the new Entity B form is loaded -- onLoad) 

pastedimage1571769013598v2.png

I could really use the community's help. Thank you in advance!

Much appreciation,

Daniel

  • DK123 Profile Picture
    DK123 65 on at
    RE: Using Javascript, how does someone check which entity a new record was created from?

    Hi Leo,

    Thanks for your response.

    I'll try formContext.data.attributes since getQueryStringParameters() function has been deprecated even though Xrm.Utility.getGlobalContext() is valid.

    I'm struggling with how to retrieve the attribute value _CreateFromType via formContext.data.attributes. I'll keep trying and update this post when I figure it out.

  • DK123 Profile Picture
    DK123 65 on at
    RE: Using Javascript, how does someone check which entity a new record was created from?

    Thanks for your response Ravi.

    Microsoft docs say that getQueryStringParameters() is deprecated. I tried Xrm.Utility.getGlobalContext().getQueryStringParameters(); and although I get the correct value in the Classic UI and the browser's dev tool console, UCI displays null/empty values which is not the expected values I see in ClassicUI and browser console.

  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Using Javascript, how does someone check which entity a new record was created from?

    Hi partner,

    You could use "Xrm.Utility.getGlobalContext().getQueryStringParameters()" instead.

    BTW, Microsoft also mentioned that we could use "formContext.data.attributes" instead.

    https://docs.microsoft.com/en-us/power-platform/important-changes-coming

    pastedimage1571796535464v1.png

    Hope it helps.

    Best Regards,

    Leo

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Using Javascript, how does someone check which entity a new record was created from?

    Hi,

    Try Xrm.Utility.getGlobalContext().getQueryStringParameters();

    querystring.png

    hope this 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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans