Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Getting Value from a record in a lookup field

Posted on by Microsoft Employee

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
    Saddamk206 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
    Community Member Microsoft Employee 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
    l ringel 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
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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
    Mihir Maruti Kadam 700 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
    CRASH 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
    Gopalan Bhuvanesh 11,397 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans