Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting Value from a record in a lookup field

(0) ShareShare
ReportReport
Posted on by

Hi all,

I'm beginner in CRM dynamic, i need to retrieve value from a column field which inside a record and the record is been call from lookup field.

Anyone there might have idea how to do it ?

Thank for the help!

*This post is locked for comments

  • Saddamk206 Profile Picture
    777 on at
    RE: Getting Value from a record in a lookup field

    Hi,

    try these:-

    var Id = Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].id;

    var Name = Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].name;

     

                             or Can Use if not work(Use window.parent. before Xrm)

    var Id = window.parent.Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].id;

    var rName = window.parent.Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].name;

  • Community Member Profile Picture
    on at
    RE: Getting Value from a record in a lookup field

    Hi,

    You can use Odata query to get data you want. i attach URL link below so that you can have some example or knowledge about the query.

    https://community.dynamics.com/crm/b/crmandunifiedservicedesk/archive/2017/04/13/javascript-odata-query

    https://dynamicscrmgirl.wordpress.com/2014/01/04/crm-2013-javascript-retrieve-record-using-odatarest-endpoint-without-jquery/

    Cheers,

  • l ringel Profile Picture
    on at
    RE: Getting Value from a record in a lookup field

    Will this help me retrieve any field within that lookup record?

    I want to run a script on load of a form that checks the value of a custom field of the related lookup record.

  • Community Member Profile Picture
    on at
    RE: Getting Value from a record in a lookup field

    Xrm.Page.ui.quickForms.get here I'm getting error and  Xrm.Page.ui.quickForms as null even I have placed QuickViewform on Form. and used msdn.microsoft.com/.../mt736908.aspx Also. I registered my javascript method on change of lookup and tried with onload too.

    Thanks in Advance.  

  • Community Member Profile Picture
    on at
    RE: Getting Value from a record in a lookup field

    Hi,

    this might be most toward my question with example, thank for the help, but the fetch xml seem a little bit complicated for me as a beginner to understand.  so i might using SDK.REST.retrieveRecord function to get value i needed.

  • Suggested answer
    Mihir Maruti Kadam Profile Picture
    702 on at
    RE: Getting Value from a record in a lookup field

    You can create and add a quick view on your form. Access data of quick view form using JS method Xrm.Page.ui.quickForms.get("<QuickViewControlName>");

    msdn.microsoft.com/.../mt736908.aspx

  • Verified answer
    CRASH Profile Picture
    2 on at
    RE: Getting Value from a record in a lookup field

    Hi,

    1) Use Xrm.Page.getAttribute("FieldName").getValue(); to get lookup value, Extract ID from the object returned.

    2) http://www.inogic.com/blog/2015/12/execute-fetchxml-using-web-api-in-dynamics-crm-2016/
    Call fetchxml(get from Advanced Find) using above or similar approach, to fetch that record you are looking for, pass ID extracted from above step, you'll get a single record, which would contain whatever data you require(mentioned in fetchXML)

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at
    RE: Getting Value from a record in a lookup field

    You want to get from JavaScript within the form?

    lookupFieldObject = Xrm.Page.data.entity.attributes.get('entityid');
        if (lookupFieldObject.getValue() != null) {
            entityId = lookupFieldObject.getValue()[0].id;
            entityName = lookupFieldObject.getValue()[0].entityType;
          entityLabel = lookupFieldObject.getValue()[0].name;
        }

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 Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,996 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans