- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 09-15-2020 08:31 AM
Limit Rows
First thought
To limit rows a quick search brought us to several sources mentioning:
var field = g_form.getField("multiple_approvers"); // multi variable set name
if (field != null) {
field.max_rows_size = 3; // number of rows allowed to be entered
}
This will make the 'Add'-button read only once you have reached the set limit (3 in the example above).
The problem
However, that is only working in the Service Portal/Mobile. As getField is not supported in Desktop.
To set the limit in both the Service Portal and Desktop you can use this script, which is a combination of several.
Solution: onLoad Catalog Client script
UI Type: All
Type: onLoad
Replace variable_set_1 with the name of your Multi Row Variable Set.
Replace the variable_set_id with the sys_id of your Multi Row Variable Set.
function onLoad() {
try { // try in service portal.
var field = g_form.getField("variable_set_1");
if (field != null) {
field.max_rows_size = 3;
}
}
catch(e){ //desktop
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("variable_set_id", 3);
}
}
The result:
After the first 2 you still see the Add button is active (left Service Portal, right back-end)
After adding the 3th it is not active anymore
Other articles on Multi Row Variable sets:
- 4,736 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very useful, better than applying the max row property, which impacts all multi rows.
Thank you very much.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very useful and easy to apply. It worked for me. Thanks