web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

How to get data from Parent Entity , Populate on Child Entity in Dynamics 365?

(1) ShareShare
ReportReport
Posted on by 5

i Dint get the Java Script Code . I got bug in that  codde Plzz provide me a best easy code for this Question. plzz

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Whats the requirement?

    You can use a real time workflow if the trigger is on the child.

  • cloflyMao Profile Picture
    25,210 on at

    Hi kartikya,

    It seems that you want to get data of record of lookup field. e.g: In contact form, get company's address of the contact and populate a specific single line text field using the value.

    If so, please try following code and check whether it works for you:

    var parentEntity = formContext.getAttribute('lookupfield_logicalname').getValue()[0];
    
    var parentEntityId = parentEntity.id;
    
    var parentEntityName = parentEntity.entityType;
    
    // Select all fields
    var filter = "";
    
    // Select address1_composite field only
    // var filter = "?$select=address1_composite";
    
    Xrm.WebApi.retrieveRecord(parentEntityName, parentEntityId, filter).then(
        function success(result) {
            console.log(result.address1_composite);
            formContext.getAttribute("childfield_logicalname").setValue(result.address1_composite);
        },
        function (error) {
            console.log(error.message);
        }
    );

    API to retrieve single entity record:

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrieverecord

    How to get and set lookup field value:

    https://blog.magnetismsolutions.com/blog/adammurchison/2017/09/20/how-to-get-and-set-a-lookup-field-using-javascript-in-dynamics-365

    Regards,

    Clofly

  • cloflyMao Profile Picture
    25,210 on at

    Hi kartikya Raina,

    Please let me know whether the code would work for you.

    Regards,

    Clofly

    If you had found any answer helped, please kindly mark as verified to close the thread, it would be really appreciated.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 76

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans