Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Retrieve Parent entity from which we open a quick create form for another entity

Posted on by 215

Hello guys,

So for this week i'm already faced with a new challenge and as always im hoping you can point me in the right direction.

At the moment i need to retrieve the id of the entity from which im opening a quick create form of another custom entity i need this so i can use in my fetch xml in order to be able to provide related records to a lookup field. Bellow is the sample of the code i have at the moment which is giving me the Invalid Child Node exception.

Xrm.Page.getControl("new_hjemmelshaver").addPreSearch(function () {
debugger;
var parentEntity = window.parent.frames[0].Xrm.Page.data.entity.getId();
var fetchRes = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='new_owner'>" +
"<attribute name='new_ownerid'/>" +
"<attribute name='new_name'/>" +
"<attribute name='createdon'/>" +
"<order attribute='new_name' descending='false'/>" +
"<filter type='and'>" +
"<condition attribute='new_realestateid' operator='eq' value='" + parentEntity +"'/>" +
"</filter>" +
"</entity>" +
"</fetch>";
Xrm.Page.getControl("new_hjemmelshaver").addCustomFilter(fetchRes);

*This post is locked for comments

  • Verified answer
    Filip Vanchevski Profile Picture
    Filip Vanchevski 215 on at
    RE: Retrieve Parent entity from which we open a quick create form for another entity

    Update

    Found a solution in case other people are having the same problem.

    I gained the entity through another lookup field that looks up to the custom entity where the subgrid from which i was opening the quick create is located.

    Code sample:

    var parentEntity = Xrm.Page.getAttribute("new_realestateid").getValue();

    var parentEntityId = parentEntity[0].id;

  • Filip Vanchevski Profile Picture
    Filip Vanchevski 215 on at
    RE: Retrieve Parent entity from which we open a quick create form for another entity

    After doing some debug i saw that i am not getting the ID as expected the result of the variable parentEntity is simply empty string.

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