- 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
05-22-2024 10:51 PM
sure