Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Adding additional rows to MRVS automatically in a Catalog item after user adds one row

GobindG
Tera Contributor

We are looking to see if it is possible to add rows automatically into the MRVS. We have a requirement to add some dependent roles when you add a row into the MRVS while submitting the request. For example: If Role1 has two dependent roles (RoleA, RoleB), When you add Role1 in the MRVS, it should add 3 rows in total. (2 more for the dependent role)

2 REPLIES 2

Kieran Anson
Kilo Patron

Hi,

Yes this is possible by using an onSubmit catalog client script that triggers on the MRVS.

 

Using g_form.getValue('your_mrvs_name') will allow you to access the stringified JSON value. Parsing this will allow you to then manipulate the data, and add values. You can the set the value.

var obj = JSON.parse(g_form.getValue('your_mrvs_name'));
obj.push({
        	variable_name: 'variable_value',
    	});
g_form.setValue("your_mrvs_name", JSON.stringify(obj));

GobindG
Tera Contributor

@Kieran Anson 
We have the Roles coming from a custom table. When you are in the Catalog Item and adding the row, it needs to be able to fetch the child roles from the custom table and add rows in real-time.