- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 08-09-2019 12:08 PM
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
- 1,034 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Rahul,
Thank you for the script.
It is working in service catalog item view but not in Service Portal, can you help me understand why it is not working?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @Community Alums / @Rahul Kathuria ,
Can you please help us your experience in making the above logic work in Service Portal.
Many thanks,
Rohit

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi all,
This seems to work in Service portal (tested on Xanadu release):
function setMaxRows(mrvsName, newSize) {
var mrvs = g_form.getField(mrvsName);
if (mrvs) {
mrvs.max_rows = newSize;
mrvs.max_rows_size = newSize;
mrvs.max_row_tooltip_msg = "You can add only " + newSize + " rows";
}
}
Usage in OP's case:
Create new 'Mobile / Service Portal' OnChange script on 'FIeld A' variable.
Script:
function onChange(control, oldValue, newValue, isLoading) {
// do nothing when it's empty, but allow processing onLoad
if (newValue == "")
return;
setMaxRows('my_mrvs_example', newValue);
function setMaxRows(mrvsName, newSize) {
var mrvs = g_form.getField(mrvsName);
if (mrvs) {
mrvs.max_rows = newSize;
mrvs.max_rows_size = newSize;
mrvs.max_row_tooltip_msg = "You can add only " + newSize + " rows";
}
}
}
Note, this will not work on Vanilla cat item view (i.e. com.glideapp.servicecatalog_cat_item_view), but our users use SP only, hence this is sufficient.
There are posts when both solutions are used combined to achieve it on both views:
Hope it helps!
Yev