javascriptdynamics-crmdynamics-crm-2016

getting display name of field in Dynamics CRM 2016


Is there a way to retrieve the display name of a field in MS CRM? So far I can only get the schema name; but I want to be able to display something a bit more user friendly. Example below would return hc_billtimeunit3 but want to return bill time unit instead.

Xrm.Page.getAttribute("hc_billtimeunit3").getName() 

Solution

  • You can use below snippet to get the label text.

    Xrm.Page.getControl("attibutename").getLabel();
    

    or

    Xrm.Page.ui.controls.get("attibutename").getLabel();
    

    Both are working seemless for me, as Xrm.Page.getControl method is a shortcut method to access Xrm.Page.ui.controls.get

    To get display name from CRM entity customizations, you may need another service call.