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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Trying to find out how to insert a child lookup into a parent lookup field value using xrm.webapi

(1) ShareShare
ReportReport
Posted on by 4
I am not sure using javascript we can create an object that will add its child lookup value  into it.
Any  help would be appreciated on this topic.
Thanks
here I am trying to add signatureLookup value to the field of queue object i.e. /emailsignature/.
I have the same question (0)
  • Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    Please refer to the following link.
    Best Regards,
    Dengliang Li
     
  • AK-24060956-0 Profile Picture
    4 on at
    Thanks Dengliang, but according to this post, we are copying the value from a system user lookup field to another system user lookup field. 
    However, what I am trying to achieve here is Queue is a parent entity here and there is a emailsignature lookup field under Queue record that I am fetching using xrm.webapi via fetchxml.
    after this fetch, I want to populate this Queue record to a From field which is a lookup for Queue records. 
    I am attaching the Queue record to From field using following snippet - 
    However this Lookup[0] Object from lookup array is a brand new record of Queue entity that is not holding any reference to emailsignature record inside it.
    can we somehow reference the emailsignature record inside lookup[0] record object ?
  • Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    Auto populating the queue to the From field can be achieved with the following code.

    function onload(executionContext) {
        var fetchXML = `?fetchXml=
    <fetch mapping='logical'>
       <entity name='queue'>
             <filter type='and'>
                <condition attribute='name' operator='eq' value='<Queue name>'/>
             </filter>
       </entity>
    </fetch>`;
        Xrm.WebApi.retrieveMultipleRecords("queue", fetchXML).then(
            function success(result) {
                var lookup = new Array();
                var lookupvalue = new Object();
                lookupvalue.id = result.entities[0].queueid;
                lookupvalue.name = result.entities[0].name;
                lookupvalue.entityType = "queue";
                lookup[0] = lookupvalue;
                executionContext.getFormContext().getAttribute("from").setValue(lookup);
            },
            function (error) {
                console.log(error.message);
            }
        );
    }
     
    Best Regards,
    Dengliang Li
     

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

News and Announcements

Season of Giving Solutions is Here!

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 > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#3
TAHER Mehdi Profile Picture

TAHER Mehdi 58

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans