Multi Row Variable Set: communication with main form


Sometimes you need to share values between variables in the main form and a Multi Row Variable Set.

Each Multi Row Variable Set has its own instance of g_form that cannot access the data in the main form.

This restriction can be solved by making the main g_form instance available to the MRVS.

The code will differ a bit between the backend and the Service Portal.

Backend

The variable set is opened in a new iFrame.

Accessing the main g_form only requires accessing the parent variable.

For instance, we can create an onLoad Catalog Client Script on the MRVS that gets the value from a variable in the main form and set it in the new row.

Service Portal

It is a bit more complicated in Service Portal. The popup is not opened in an iframe, so we will need two steps to achieve the same result.

Making main g_form available

We can set the g_form as a global variable in an onLoad Catalog Client Script in the Catalog Item.

Note: Set Isolate Script to false.

Accessing g_form from the MRVS

Create an onLoad Catalog Client Script in the MRVS to access the global variable.

Example

Pre-filling a variable in the MRVS with a value from the main form.

The date selected in the “From” field in the main form is copied to the “To” field in the MRVS.

Multirow Variable Set Service Portal
Warning: Tested in Chrome in New York. Don’t use unless strictly necessary. It might break in future releases.


Rubén

About Rubén

Rubén is a certified ServiceNow System Administrator, Implementation Specialist and Application Developer. He works as Senior Consultant for DXC Fruition in Spain since 2014 and has strong experience in configuration and implementation for major European companies.