Announcements
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.
Any help or suggestion is much appreciated.
Thanks,
Gowtham
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
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
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.
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);
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156