Update Lookup Field Display Name in Dynamics 365 with JavaScript

Fredrik Engseth
4 min readFeb 1, 2023
Gif showing how it looks when changing the display name using JavaScript

This article explains how to update the lookup field display name in Dynamics 365 with JavaScript. The steps involve adding a JavaScript function that retrieve related record and fields from the related table, and updating the display name accordingly. The function can be added to the on-change and on-load events of the form, and the changes will only be reflected on the record referencing the lookup record. The article also includes examples of the JavaScript code for adding both the product name and number or only the product number as the display name.

Table of Content

  • Update Lookup Display Name with JavaScript
  • How to Add the JavaScript Function to the Form
  • Conclusion
  • Resources

Prerequisites

  • Familiar with Dynamics 365
  • Familiar with JavaScript

Update Lookup Display Name with JavaScript

In this example, we look at how we can update the lookup field display name of the product table in Dynamics 365 with JavaScript. By showing the product number in addition to the name of the product, or only the product number. In the image below the default display name of the…

--

--

Fredrik Engseth

Developer | Dynamics 365 | Power Platform | Azure | Personal development | Investments | ☕ https://www.buymeacoffee.com/fredrikengseth