- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 03:48 AM
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.
Any pointers on this will be appreciated.
Thanks,
Krishna
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 04:01 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 04:01 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 05:33 AM
Thanks Ankur for your response. This helped
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 10:13 PM
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.
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 10:45 PM
Can you post a new question and share all the details there and tag me as this is an old post?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader