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)

Lookup field object doesn't contain ID Value in CRM 2016.

(0) ShareShare
ReportReport
Posted on by

Hi guys. I am having issue, my lookup field doesn't have ID value. It does have only name of entity and entity type but not ID. We use ID  to retrieve another records via AJAX. Has someone encountered with the same issue?. Is there any another solution to get ID value from Lookup field.? Thank you for your help.

*This post is locked for comments

I have the same question (0)
  • Mahendar Pal Profile Picture
    45,095 on at

    Hi Michal,

    It's not possible, every record have it's own GUID, and when we are referring any record in lookup it's based on id only. can you share you code here for inquiry  ??

  • Michal Sivak Profile Picture
    on at

    Hi HIMBAP, thank you for your replay. Yes I know every record must have own GUID. But somehow when I try to retrieve value from lookup field for Site ID

    var siteId = Xrm.Page.getAttribute("new_siteconsultationid").getValue()[0].id;  it shows me that id doesn't exist or is undefined. When I debug code via developer tool it shows me that looup field holds only the name and entitytype name value, but not ID. is it possible ?I talk about CRM 2016 with update. Thank you for your help

  • Mahendar Pal Profile Picture
    45,095 on at

    It seems very strange, I will appreciate if you can share screenshots of your watch window for more clarity. Also can you provide some more details about entity is it a custom entity or system site entity ?? Thanks

  • Rickard Norström Profile Picture
    on at

    Hi,

    How is that lookup set? Is it the same for all records or just for some?

    Regards

  • Suggested answer
    Michal Sivak Profile Picture
    on at

    Hi Guys, I already fixed. It was my mistake I had forgotten to include Id in lookupItem object so that's why on load the lookup field didn't have ID. Strange that didn't throw error.

            //set up the lookup fields

     var lookupData = new Array();

       var lookupItem = new Object();

         lookupItem.typename = value.LogicalName;

         lookupItem.name = value.Name;

        // lookupItem.id = value.Id; - this one was missing

         lookupData[0] = lookupItem;

       Xrm.Page.getAttribute(fieldName).setValue(lookupData);

    Thank you guys for help.

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