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.
-
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);
-
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);
-
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);
-
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);
- On the other hand, you can use the function getLabel() to return the label for the control
Hope This Helps!
*This post is locked for comments