Approvers field (u_approvers) maximum 2 entries are allowed to be selected

DeepikaR1661877
Tera Contributor

Hello All,

Currently i am working in incident from, in that from i need set when source field is ABC then Approvers field (u_approvers) maximum 2 entries are allowed to be selected, so i have tried the below script by using BR, but it's not working any one help one this?

(function executeRule(current, previous /*null when async*/) {
var maxApprovers = 2;
var approvers = current.approvers.toString().split(',');
if (approvers.length > maxApprovers) {
gs.addErrorMessage('You can select a maximum of ' + maxApprovers + ' approvers.');
current.setAbortAction(true);
}
})(current, previous);

1 ACCEPTED SOLUTION

Yes, the field names referenced in scripts should be their true names (element), not their display names (column_label).

View solution in original post

3 REPLIES 3

Nicholas_Gann
Mega Guru

Your script should work. You mention the incident table but approvers in the script is not a field that i see and you've referenced u_approvers in the text above. Have you validated the field name?

 

Additionally is this Business Rule running on Update and Insert and is the 'When' set to Before?

Hi @Nicholas_Gann 

Yeah validated the field name is Approver and the backend name is u_approver , so i need change the approver to u_approver? And i m set the BR condition when set before

Yes, the field names referenced in scripts should be their true names (element), not their display names (column_label).