Hello together
I have a problem with a function in the Xrm.Page-Library:
I want to fill the labels (display name) of all "recommended" fields in a string. Unfortunately, this function gives me not only the display name as result, but also the tooltip of the field.
Example:
Expected Result: "Accountname"
Result: "Accountname Type the company or business name."
I also get the tooltip text and that's wrong. The function GetLabel() should get me the label and not the description of the field.
Can you help me with this issue?
Code:
for (var i in attributes) {
if (Xrm.Page.getAttribute(attributes[i].getName()).getRequiredLevel() == "recommended") {
if (alertString == "") {
alertString = Xrm.Page.getControl(attributes[i].getName()).getLabel();
}
else {
alertString += ", " + Xrm.Page.getControl(attributes[i].getName()).getLabel();
}
}
}
Thanks for your help :)
Kind regards, Dominik
*This post is locked for comments
Hey Luke
Thanks :) it works!
Yes, this annoyed me too. Ended up using the split function to extract the label as follows:
var label = Xrm.Page.getControl(field).getLabel();
var fieldNameArray = label.split(/\n/);
var fieldName = fieldNameArray[0];
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156