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 CRM (Archived)

Retrieve lookup value using fetchXML.

(0) ShareShare
ReportReport
Posted on by 111

Below is my code, how to retrieve look up value and set.

var fetchxml="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"+
"<entity name='team'>"+
"<attribute name='name' />"+
"<attribute name='businessunitid' />"+
"<attribute name='teamid' />"+
"<attribute name='teamtype' />"+
"<attribute name='jd_securityconfigsid' />"+
"<order attribute='name' descending='false' />"+
"<link-entity name='teammembership' from='teamid' to='teamid' visible='false' intersect='true'>"+
"<link-entity name='systemuser' from='systemuserid' to='systemuserid' alias='ag'>"+
"<filter type='and'>"+
"<condition attribute='systemuserid' operator='eq' uiname='Sales User' uitype='systemuser' value='"+lookupid+"' />"+
"</filter>"+
"</link-entity>"+
"</link-entity>"+
"</entity>"+
"</fetch>"
var s = XrmServiceToolkit.Soap.Fetch(fetchxml);
if (s.length > 0)
{

for (var i = 0; i < s.length; i++)
{

Team=s[i].attributes.name.value;

var temp=s[i].attributes.jd_securityconfigsid[0].formattedValue;

var nameOfLookup =s[i].attributes.jd_securityconfigsid.id;


}
}


}
Xrm.Page.getAttribute('description').setValue(nameOfLookup);

Xrm.Page.getAttribute('jd_role').setValue(temp);

}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Amos .

    Try with this  -

                   var IDOfLookup =s[i].attributes.jd_securityconfigsid.id;
                   var nameOfLookup =s[i].attributes.jd_securityconfigsid.name;


  • Amos Dave Profile Picture
    111 on at

    "jd_securityconfigsid" is a lookup field. and  i want to set the value of that lookup in some other field.

  • Amos Dave Profile Picture
    111 on at

    Thank you Goutam, I will try this. :)

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Amos ,

    You can get the code how to set lookup value here  -

    goutamdascrm.wordpress.com/.../how-to-set-lookup-field-value-using-javascript-dynamics-crm

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans