Validation on Multi Row Variable Set

Krishna73
Tera Expert

Hi All,

I have a requirement in MRVS, where I have added a field called Proportion. Now the requirement is - restrict the Add button based on the Proportion (sum of all) value. If it is less than 100 then I should able too add more untill the sum of all reaches to 100.

find_real_file.png

Any pointers on this will be appreciated.

 

Thanks,

Krishna

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you cannot have onChange validation on MRVS variable set.

So the only way is:

1) create onSubmit client script which applies on UI Type - ALL and Applies on Catalog Item

2) parse the JSON value from MRVS

3) sum up all the values

4) if it is more than 100 then ask user to remove rows and stop form submission

function onSubmit(){

var values = g_form.getValue('mrvsVariableName'); // give here mrvs variable name

var total = 0;

var parser = JSON.parse(values);

for(var i=0;i<parser.length;i++){

total = total + parseInt(parser[i].proportionVariableName); // give here the variable name for proportion

}

if(total >100){

g_form.addErrorMessage('Not allowed beyond 100 proportion');

return false;

}

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

sure