Parse values in MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Hi Team,
I am creating a catalog item to modify the CI Attributes.
Form Design is:
CI name is 'List Collector' type referencing to CMDB table.
Requirement: is Whatever CIs user selects in 'CI Name' field, its corresponding attributes should be shown as a dropdown list on the below field. ('select the field you want to modify). User should be able to select multiple attributes from dropdown list.
But, I did not find the correct field type for this.
Hence, I thought of MRVS.
But, issue is that, I am not able to apply the script on MRVS variable.
Script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
25m ago
Hi there,
To achieve this using a Multi-Row Variable Set (MRVS), you need to change your approach slightly. You cannot easily push data into the MRVS dropdown from the main form's script.
Instead, you must pull the data from inside the MRVS when the user clicks "Add".
Here is the technical solution:
The Variable: Inside your MRVS, create a variable (e.g., attribute_to_modify) of type Select Box.
The Script: Create a Catalog Client Script applied specifically to the Variable Set (not the Catalog Item).
Configuration:
Applies to: A Variable Set
Variable Set: [Your MRVS Name]
Type: onLoad
UI Type: All
The Code: Use g_service_catalog.parent.getValue() to access the CI field that sits on the main form behind the modal.
function onLoad() { // 1. Get the CI list from the PARENT form (outside the MRVS) var parentCI = ""; if (typeof g_service_catalog !== 'undefined' && g_service_catalog.parent) { // Service Portal / Employee Center method parentCI = g_service_catalog.parent.getValue('ci_name'); } else { // Fallback for Native UI (if needed, though rare for Catalog these days) try { parentCI = parent.g_form.getValue('ci_name'); } catch (e) { console.log("Could not find parent form"); } } // 2. Define the variable name INSIDE the MRVS var targetVar = 'attribute_to_modify'; // Replace with your actual MRVS variable name // If no CIs selected, stop here if (!parentCI) return; // 3. Call your existing Script Include var ga = new GlideAjax('GetCIAttributes'); ga.addParam('sysparm_name', 'getFieldsForCIs'); ga.addParam('sysparm_ci_list', parentCI); ga.getXMLAnswer(function(answer) { g_form.clearOptions(targetVar); g_form.addOption(targetVar, '', '-- None --', 0); if (!answer) return; var arr; try { arr = JSON.parse(answer); } catch (e) { return; } // 4. Populate the dropdown inside the Modal arr.forEach(function(f) { if (f && f.value) { g_form.addOption(targetVar, f.value, f.label); } }); }); }
How this works for the user:
User selects CIs on the main form.
User clicks "Add" on the MRVS table.
The popup opens.
The script runs immediately (onLoad of the popup), grabs the CIs from the background form, and fills the dropdown.
User picks an attribute and saves the row.
User can repeat this to add multiple attributes.
If this solution helps you achieve the requirement, please mark it as Accepted Solution.
Best regards,
Brandão.
