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 :
Customer experience | Sales, Customer Insights,...
Answered

How to change the display name of the lookup field

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Check this - fredrikengseth.com/.../

  • Gowtham89 Profile Picture
    on at

    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);

  • Suggested answer
    Yoshika Suzuki Profile Picture
    on at

    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
    on at

    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

  • Gowtham89 Profile Picture
    on at

    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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans