Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archive)
Suggested answer

How to Map Lookup field to other entity look up field

(0) ShareShare
ReportReport
Posted on by 20

Hi All,

I am trying to map the lookup field of account entity to contact entity lookup field by using the workflow and tried with CRUD operations but i did not get the out put. Please help me.

Requirement is that on create of account record all the values mentioned in account entity with same values a duplicate record should be created in contact entity.

I am facing difficulty in getting and setting the lookup field. I tried this with CRUD operation but no luck. 

Thanks and Regards,

New to Ms Crm Dynamics

Sultan

  • Suggested answer
    Shaik Sultan Profile Picture
    20 on at
    RE: How to Map Lookup field to other entity look up field

    Hi,

    I tried the workflow record is getting created but the lookup field and optionset fields are not mapping in contact entity record. 

  • Suggested answer
    Abdul Wahab Profile Picture
    12,068 Moderator on at
    RE: How to Map Lookup field to other entity look up field

    Hi Shaik Sultan,

    Did you try the workflow?

    pastedimage1671478671298v1.png

    pastedimage1671478708022v2.png

  • Shaik Sultan Profile Picture
    20 on at
    RE: How to Map Lookup field to other entity look up field

    Hi Haritha,

    If you have look at the code you will know where i have to make the corrections.

    function CreateRecordInContact (executionContext) {

       var formContext = executionContext.getFormContext();

       var LName = formContext.getAttribute("name").getValue();

       var AccountLookup = formContext.getAttribute("new_contactlookup").getValue();

       var entity = {};

       entity.lastname = LName;

       entity["cr04d_accountlookup@odata.bind"] = AccountLookup;

      // entity.creditonhold = null;

       var req = new XMLHttpRequest();

       req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/contacts", true);

       req.setRequestHeader("OData-MaxVersion", "4.0");

       req.setRequestHeader("OData-Version", "4.0");

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       req.onreadystatechange = function () {

           if (this.readyState === 4) {

               req.onreadystatechange = null;

               if (this.status === 204) {

                   var uri = this.getResponseHeader("OData-EntityId");

                   var regExp = /\(([^)]+)\)/;

                   var matches = regExp.exec(uri);

                   var newEntityId = matches[1];

               } else {

                   Xrm.Utility.alertDialog(this.statusText);

               }

           }

       };

       req.send(JSON.stringify(entity));

    }

  • Haritha222 Profile Picture
    120 on at
    RE: How to Map Lookup field to other entity look up field

    community.dynamics.com/.../mapping-lookup-fields

    Please refer above link.it may be helpful

  • Suggested answer
    Shaik Sultan Profile Picture
    20 on at
    RE: How to Map Lookup field to other entity look up field

    Thanks for your response.

    I tried with the mentioned steps but no output.

    Record must be created in contact entity if we create the record in account entity. Record is getting created but the value mentioned in lookup field is not populating in contact entity record.

    Kindly provide me some reference this will help me.

  • Haritha222 Profile Picture
    120 on at
    RE: How to Map Lookup field to other entity look up field

    Hi Shaik,

    Please try below steps

    1.Goto advanced settings

    2.select patch/solution

    3.select account entity

    4.select relationship(Contact & Account)

    5.Under information ,mappings is there

    6.Create a new mapping (select fields )

    Note: Map fields with same datatype

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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans