The CreatorCon Call for Content is officially open! Get started here.

passing a variable from MRVS to main form catalog

divyabodireddy
Tera Contributor

I have a Multi Row Variable Set (MRVS) that includes a variable named location (type: Select Box) with the following choices:

  • Fourth Floor
  • Fifth Floor
  • Seventh Floor
  • Tenth Floor

Outside the MRVS, I have a variable named standards_access.
I want standards_access to be visible only when any row in the MRVS has location set to "Fourth Floor" or "Seventh Floor".

I previously used a checkbox variable (flag) to set a value to true, and based on that, made standards_access visible. This approach works in the standard UI, but not in Service Portal.

 

script:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    if (newValue === "Executive Suite" && parent.g_form) {
        g_form.addInfoMessage(parent.g_form.getValue("flag"));
        parent.g_form.setValue('flag', true);
        g_form.setVisible('standards_access', true);
    }
}

 

3 REPLIES 3

divyabodireddy
Tera Contributor

 if (newValue === "Executive Suite" && parent.g_form) in this step I used the selected variables inside the location field.

Ankur Bawiskar
Tera Patron
Tera Patron

@divyabodireddy 

try this

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    try {
        if (window == null) {
            // portal
            if (newValue === "Executive Suite" && g_service_catalog.parent.getValue('flag')) {
                g_form.addInfoMessage(g_service_catalog.parent.getValue("flag"));
                g_service_catalog.parent.setValue('flag', true);
                g_form.setVisible('standards_access', true);
            }
        }
    } catch (ex) {
        // native
        if (newValue === "Executive Suite" && parent.g_form) {
            g_form.addInfoMessage(parent.g_form.getValue("flag"));
            parent.g_form.setValue('flag', true);
            g_form.setVisible('standards_access', true);
        }
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

divyabodireddy_0-1759847082887.png

you can see the flag is not becoming true. when I select the executive, it shows me as false.