Lets take an example of a multi-select picklist having 5 values:
- Banana
- Orange
- Strawberry
- Guava
- Grapes
While working on the form, if a user selects only 2 out of these, e.g:
- Banana
- Guava
Following JavaScript will return the count of selected values in the multi-select picklist i.e. 2.
function GetMultiSelectPicklistLength(executionContext)
{
var length = 0;
var formContext = executionContext.getFormContext();
var multiSelectField = formContext.getAttribute("new_MultiselectPicklist");
if(multiSelectField != null)
{
var fieldValue = multiSelectField.getText();
if(fieldValue != null)
{
lengthValue = fieldValue.length;
}
}
return length;
}
No comments:
Post a Comment