Change CRM Field and Section Label at Runtime


Some time we need to change CRM field label at runtime. This can be easily implemented through JS code. You can change like below

crmForm.all.FieldName_c.innerText=”New Label”;

you can include this code on any form event based on your requirement. I got one question on CRM Forum where user need to change CRM field label at runtime based on Picklist value.

For example we have a Picklist “Type” with two items “Customer” and “supplier” and we have another field named “Name” we want to change label of this field based on the value selected from picklist like

If user selects “Customer” then caption of the field should be “Customer Name” and if user selects “Supplier” then caption should be “Supplier Name”. so this can be implemented like below

if(crmForm.all.Type.SelectedText==”Customer”)

crmForm.all.name_c.innerText=”Customer Name”;

else if(crmForm.all.Type.SelectedText==”Supplier”)

crmForm.all.name_c.innerText=”Supplier Name”;

Also some time we need to change caption of the Section, as section is a Table basically so you need to get it’s GUID first then based on GUID you can change it’s innerText property like below

document.getElementById(‘{GUID of section}’).cells[0].innerText=”New Label”;

and GUID of the section can be easily get through Developers tool or through view->source

Hope it will help somebody !!!

Advertisements

2 Comments

Filed under MS CRM & Javascript

2 responses to “Change CRM Field and Section Label at Runtime

  1. Ramesh

    Hey,
    this is very helpful for me,,

    I am very thankful to you,,
    Regards,
    Ramesh

  2. df.h

    Hey thanks a lottt

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