Skip to main content

Notifications

Announcements

No record found.

CHANGE CONTROL LABEL DURING RUNTIME IN DYNAMICS 365 USING JAVASCRIPT

In Dynamics 365, we might have to change CRM control label at runtime for specific needs.

This can be easily done through JavaScript code by calling the function setLabel() that sets the label of the control.

One function, several ways you can use to change the label based on the control type.
  1. Dynamically change a tab label
    Using the function setLabel, you can change a tab label during runtime as per the below code snippet.

    var runtimeTabLabel = "Runtime Tab Label";
    formContext.ui.tabs.get("<tabName>").setLabel(runtimeTabLabel);


  2. Dynamically change section label
    Using the function setLabel, you can change a section label during runtime as per the below code snippet.

    var runtimeSectionLabel = "Runtime Section Label";
    formContext.ui.tabs.get("<tabName>").sections.get("<sectionName>").setLabel(runtimeSectionLabel);


  3. Dynamically change field label
    Using the function setLabel, you can change a field label during runtime as per the below code snippet.

    var runtimeFieldLabel = "Runtime Field Label";
    formContext.getControl("<fieldName>").setLabel(runtimeFieldLabel);


  4. Dynamically change subgrid label
    Using the function setLabel, you can change a subgrid label during runtime as per the below code snippet.

    var runtimeSubgridLabel = "Runtime Subgrid Label";
    formContext.getControl("<subgridName>").setLabel(runtimeSubgridLabel);


    Change Control label

  5. On the other hand, you can use the function getLabel() to return the label for the control


Hope This Helps!

This was originally posted here.

Comments

*This post is locked for comments