Can I control (make readonly/mandotory...) variables inside a multi row variable set

F_bio Santos
Kilo Sage

Can I control (make readonly/mandotory...) variables inside a multi row variable set with a catalog ui policy inside the item and not inside the variable set ?

Im trying to make a variable that in inside a MRVS read-only based on the value of a field that is on the item is this possible ? (Zurich Version)

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Seems backwards and unnecessary, since the values in each row are already read-only when viewed on the Catalog Item form.  Just create an onLoad Catalog Client Script that applies to the MRVS, which will run when the Add Row button or Edit icon is clicked - so it will be in effect in the add/edit row dialog window:

function onLoad() {
    if (g_service_catalog.parent.getValue('var_name') == 'create') {
        g_form.setValue('add_remove', 'add');
        g_form.setReadOnly('add_remove', true);
}

 

View solution in original post

7 REPLIES 7

Hey There, that error happens because g_form.getSections() isn’t a real ServiceNow function — it returns undefined, so .forEach() can’t run on it.

For MRVS rows, you need to use g_form.getSectionCount('access_managment') to get how many rows there are, then loop like this:

 

var rowCount = g_form.getSectionCount('access_managment'); for (var i = 0; i < rowCount; i++) { g_form.setValue('add_remove', 'add', i); g_form.setReadOnly('add_remove', true, i); }
 

Make sure the MRVS name (access_managment) is exactly right (watch spelling and case).

This way, you set the value and make the field read-only for every row in the MRVS.

 

@F_bio Santos  - Please give a Thumbs up and Accepted Solution if you find Helpful! Thanks My Friend!

PrashantLearnIT
Tera Sage

Hi @F_bio Santos  @Matthew_13 

 

Yes, we can do read only in multi row variable set from catalog item in Zurich release.

 

Below screenshots mentions all in Zurich version: 

.

PrashantLearnIT_0-1766422093493.png

 

 

Screenshot 2025-12-22 221546.png

 

Screenshot 2025-12-22 221603.png

 

Screenshot 2025-12-22 221617.png

 

 

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

Brad Bowman
Kilo Patron
Kilo Patron

Seems backwards and unnecessary, since the values in each row are already read-only when viewed on the Catalog Item form.  Just create an onLoad Catalog Client Script that applies to the MRVS, which will run when the Add Row button or Edit icon is clicked - so it will be in effect in the add/edit row dialog window:

function onLoad() {
    if (g_service_catalog.parent.getValue('var_name') == 'create') {
        g_form.setValue('add_remove', 'add');
        g_form.setReadOnly('add_remove', true);
}