Howto: Get label for an attribute with JavaScript

If you have to retrieve the label of an attribute in a form script, you have two options. The first one, is of course not supported, but quick and easy to implement.

function GetFieldLabel(fieldname)
{
  var field = crmForm.all[fieldname+ '_c'];
 
  if (field != null){
    return field.firstChild.firstChild.nodeValue;
  }
  else {
    return '';
  }
}
 
alert(GetFieldLabel('subject'));

The other option is, to retrieve the label for the user language from the crm service. I will cover this in another article.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.