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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

getText API behavior changed

Guido Preite Profile Picture Guido Preite 54,086 Moderator
Some days ago I was upgrading some JavaScript files to v9 and I noticed one of the scripts was not working correctly.
The specific code was using the getText function in order to retrieve the label of an optionset field. The getText function used to return an empty string in Dynamics instances prior to CRM 2016, but in recent versions it returns null. If you need to handle the label in your code (like showing some alerts) the check should be like this one:

function checkOptionsetLabel(context, fieldName) {
var selectedLabel = context.getAttribute(fieldName).getText();
if (selectedLabel != null) {
// ...
}
}
Also the official documentation has been updated to highlight the return value. Hope it helps!

This was originally posted here.

Comments

*This post is locked for comments