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

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

 

Thanks Ankur for your response. This helped 

Hi @Ankur Bawiskar,

 

Validation on Multi Row variable set environment_selections (same role cannot be allowed).

 

Under a multi-row variable set, select_environment and select_role select box fields are both are select box fields.

 

A requester could request different roles for the same environment this can't be allowed.

For ex. I could select both the user and the viewer roles for ARCS UAT. Please check below.

 

Shidhi_0-1716440712223.png

 

However, only one role per environment is allowed to be selected. If multiple roles are selected for the same environment, an alert must come saying that the selected environment is already added and clear the chosen environment field value.

 

I'm not sure how to check two variables. Please help me with this. 

 

Thank you!

 

 

 

@Shidhi 

Can you post a new question and share all the details there and tag me as this is an old post?

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