Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications

|

How to Rename Columns on Views

Post Author: Divyani Rajani |

In today’s business scenario, we examine the common need to rename columns fetched from related entities when adding them into views. When we add any column from a related entity in the view, by default the naming convention of that column is ColumnName (Related Entity Name). This might confuse end users.

Graphical user interface, text

Description automatically generated

However, the existing column of the current entity remains the same as its Display Name.

Graphical user interface, text, application

Description automatically generated

In this blogpost, we will see how we can rename related entity columns on views. We can achieve this in a couple of different ways:

Option 1:

We can create a calculated column in the current entity with the new name we need and populate the value from the related entity column into it.

Create new calculated column

Graphical user interface, application, Teams

Description automatically generated

Set the calculated field from lookup entity

Graphical user interface, application

Description automatically generated with medium confidence

And then use this new calculated field in the view. With that, the new column will have the data from the related entity and the name as we need it.

Graphical user interface, text, application

Description automatically generated

But with this approach we will be limited to the data types of the column, as Calculated field is available only for the below data types:

  • Single line of text
  • Option Set
  • Two Options
  • Whole Number
  • Decimal
  • Currency
  • Date and Time

Now, if we have any other column – like choices, file, or any other data type apart from above for which calculated column is supported – this option won’t work.

There’s another simple method with which we can rename the column using jQuery.

Option 2:

Create a JavaScript function in web resource and add that web resource and function name on the select column of the view.

Create new web resource and publish it.

Graphical user interface, application

Description automatically generated

Add below code to viewscript.js file

function changeColumnText(){
    if (typeof($) === 'undefined') {
        $ = parent.$;
        jQuery = parent.jQuery;
    }
    $(document).ready(function () {
        $("label:contains('columnName')").text('newColumnName');
    });
}

Graphical user interface, text, application, Teams

Description automatically generated

Then add this web resource to the column in the view.

Note: To select the web resource on column from view, we need to switch to classic mode

Graphical user interface, application

Description automatically generated

Double click the column to open column properties, add the web resource and provide function name

Graphical user interface, application

Description automatically generated

Click Ok and then Save the view.

Graphical user interface, application

Description automatically generated

Once this code is added we’ll see newColumnName appears on the view.

Before : columnName = Price (Price)

Graphical user interface

Description automatically generated

After : newColumnName = Price

Graphical user interface, text, application, Word

Description automatically generated

In case if it doesn’t reflect right away, publish all customizations of an entity, and recheck.

Happy Dynamics 365'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

Leave a Reply

Your email address will not be published.

PowerObjects Recommends