Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

How to change the display name of the lookup field

Posted on by 134

Hello,

I am new to CRM and I am looking for an help to change the display name of the lookup field in related entity. By default the lookup shows the primary column field name, but instead I wanted the lookup to show other field name within the table. I have come across the below URL, but the given code doesn't seem to work.

https://learn.microsoft.com/en-us/archive/blogs/paf/how-to-display-related-entity-field-in-a-crm-lookup-instead-of-the-primary-entity-field 

Any help or suggestion is much appreciated.

Thanks,

Gowtham

  • Gowtham89 Profile Picture
    Gowtham89 134 on at
    RE: How to change the display name of the lookup field

    Thank you so much, I was able to figure out the issue and the functionality is working now as suggested. Thanks again for your assistance.

    Thanks

    Gowtham

  • Gowtham89 Profile Picture
    Gowtham89 134 on at
    RE: How to change the display name of the lookup field

    Thank You,

    The above code is to change the display name of the lookup field. But it doesn't do anything and it doesn't throw any error as well, which makes me believe I am going wrong somewhere. Need help to understand if I have customised the JS correctly.

    Thanks

    Gowtham

  • Suggested answer
    RE: How to change the display name of the lookup field

    As mentioned in the comments, customization is required to change the display name of the lookup field.

    The items displayed during a lookup search can also be defined in the lookup view columns.

  • Gowtham89 Profile Picture
    Gowtham89 134 on at
    RE: How to change the display name of the lookup field

    Hello,

    Thank you so much for this. This scenario is similar to mine where I am trying to show Product description instead of Product ID (Unique Identifier) field. I tried using the same code but I don't see anything happening, no errors and the functionality is not working as well.

    This is my code. I have created a lookup for choosing Product within the 'Services' table. I want the Product lookup to show the display name from description field instead of product number.

    Lookup Name : m***_product

    Unique identifier of Product table - productnumber (Product table)

    the field value that needs to be shown. - description (Product table)

    var sdk = window.sdk || {};

    (function (setProductDisplayName) {

       "use strict"

       this.setProductDisplayName = async function (executionContext) {

           const formContext = executionContext.getFormContext();

           let productColumn = formContext.getAttribute("productnumber");

           let productValue = (productColumn === null) ? null : productColumn.getValue();

           if (productValue !== null) {

               let productnumber = productValue[0].id.replace(/{|}/g, "");

               await Xrm.WebApi.retrieveRecord("product", productnumber).then(

                   function success(result) {

                       if (productValue[0].name === result["name"]) {

                           productValue[0].name = `${result["description"]}`

                           productColumn.setValue(productValue);

                       }

                   },

                   function (error) {

                       console.log(error.message);

                   }

               );

           }

       }

    }).call(sdk);

  • Verified answer
    a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: How to change the display name of the lookup field

    Hello,

    Check this - fredrikengseth.com/.../

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans