web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Replace label control display name with description

(0) ShareShare
ReportReport
Posted on by 35

I'm trying to replace the display name of the control with description since display name is not allowing more than 100 characters. 

                    formContext.getControl("logicalNamei").setLabel("longText having more than 100 char");
The above script is working, But I do not want to have label in two different places (like display Name and JavaScript). I'm looking JavaScript {like below} which is taking value from description and replacing into label display name
formContext.getControl("logicalNamei").setLabel("description of that label");
I have the same question (0)
  • Suggested answer
    Flydancer Profile Picture
    1,332 on at

    You can get the Descriptions by retrieving the entity metadata: carldesouza.com/.../ and then replacing the Labels like you did in your example

    Keep in mind that the description fields are also limited to only 200 characters.

  • Verified answer
    Eiken Profile Picture
    Microsoft Employee on at

    Hi,

    It is possible to do this by getting the entity metadata description via JS

    Now I try to replace label control display name of "Phone" with description.

    pastedimage1671184098664v1.png

    pastedimage1671184112264v2.png

     This is the JS code and I will post the code on the back.

     pastedimage1671184258724v3.png

    Then refresh and the display name of Phone is changed.

    pastedimage1671184273934v4.png

    function changeLabel(e){
    var req = new XMLHttpRequest();
    var formContext = e.getFormContext();
    req.open("GET", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.0/EntityDefinitions(LogicalName='cr932_students')/Attributes?$select=SchemaName,Description", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 200) {
                var results = JSON.parse(this.response);
                for (var i = 0; i < results.value.length; i++) {
                    if(results.value[i].SchemaName=="cr932_Phone"){
                    var newLabel= results.value[i].Description.LocalizedLabels[0].Label
                    console.log(newLabel);
                    formContext.getControl("cr932_phone").setLabel(newLabel)
                    }
                }
               
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send();

    }
  • ABDwbg Profile Picture
    35 on at

    Hi Its working for few controls, But for few control SchemaName coming endswith "Name".

    My schema name "isactivitiesincludedspecificaction" But its coming with isactivitiesincludedspecificactionName .

    Because of this below condition is failed for few controls in the form.

    if(results.value[i].SchemaName=="isactivitiesincludedspecificactionName ").

  • Eiken Profile Picture
    Microsoft Employee on at

    Hi,

    I think that it has nothing to do with "Name" because I test with a schema name ending with "Name", it still works.

    Maybe you need to check the SchemaName and Logical name.

    pastedimage1671516133506v1.png

    pastedimage1671516177811v2.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 135

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 82 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 57

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans