CRM 2011 – How to set an attribute label in Javascript

It took me a while to figure this out but finally thanks to this forum post I did it.  I think what was confusing me was you had to get the control and then set the label.

var affectedControl = Xrm.Page.ui.controls.get(fieldname);

var affectedAttribute = Xrm.Page.data.entity.attributes.get(fieldname);

affectedAttribute.setRequiredLevel(‘required’);

affectedControl.setLabel(‘New label’);

7 thoughts on “CRM 2011 – How to set an attribute label in Javascript

  1. Janet Thomas November 1, 2012 / 6:06 pm

    Found a few interesting things with this. First, if your field is required, you lose the red * if you change the label. The field is still required but no *. Also, if you change the label and then in jscript try to change the required level (e.g. Xrm.Page.getAttribute(“new_myfield”).setRequiredLevel(“required”);), you get an error.

    Like

  2. V August 20, 2013 / 1:00 pm

    Thanks,

    Working like a charm

    Like

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.