Relabeling Composite Control Fields


We can change display name of the entity fields easily by editing field display name property. But we can’t change fields label used in address composite controls. In this post we are demonstrating how to relabel composite control fields.

Requirement:Relabel city field in address composite control in account entity.

Note: You can’t change field logical name once it is created.

Solution: We can implement this requirement using Java Script. We have option to access composite control using Java Script, we can refer them using following way:

<composite control name>_compositionLinkControl_<constituent attribute name>

So if we want to refer any field which is used in the composite control, We can do like following, we are accessing city field here:

<composite control name>_compositionLinkControl_address1_city

To relabel the normal fields, we can use setLabel method. so we can use the same method to relabel city as well. let’s say we want to rename city field to “Distric”. We can use following code for that:

Xrm.Page.getControl(‘address1_composite_compositionLinkControl_address1_city’).setLabel(“District”);

Similarly we can refer other fields as well.You can refer composite control name from the respective entity form or you can also refer it here.

Using Code: To use this code we need to create Java Script web resource, where we can have below method. We need to call this method on Onload of the account entity form.

function RelableAddressControl()

{

Xrm.Page.getControl(‘address1_composite_compositionLinkControl_address1_city’).setLabel(“District”);

}

accountform

Now after publishing our changes, when we will open any account record we will see changes like below:

addressfield

HIMBAP | Need any help in Microsoft CRM 2015 Development Contact US !!

Advertisements

Leave a comment

Filed under MS CRM 2011, MS CRM 2013, MS CRM 2015, MS CRM 2015 Update 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s