To conditionally restrict the number of rows in Multi variable set
Hi All, Below script will help if you conditionally want to restrict the number of rows in multi-variable set.
//This script will allow you to add 5 rows in MVS if you selected 5 in field A and so on.
Field A - Select box variable with choice values (1-10)
Field B - Multi-Variable set
On-Change catalog client script on field A.
------------------------------
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ServerSize = g_form.getValue('Field_A'); //Select box variable
function setMaxRowSize (sysIdMRWS, limit) {
var tableVariable = typeof tableVariableCache !== "undefined" &&
tableVariableCache["table_variable_buttons_" + sysIdMRWS] != null ?
tableVariableCache["table_variable_buttons_" + sysIdMRWS] :
typeof table_variable !== "undefined" ? table_variable: null;
if (tableVariable != null) {
if (typeof tableVariable.setMaxRowSize === "function") {
tableVariable.setMaxRowSize(String(limit));
} else {
tableVariable.maxRowSize = limit;
}
}
}
setMaxRowSize("feb9ad834fe9f300b8580ab18110c719", ServerSize); //sys_id of MVS
}
Hope this helps.
Thanks
Rahul Kathuria
https://www.servicenow.com/community/developer-articles/to-conditionally-restrict-the-number-of-rows-in-multi-variable/ta-p/2305240