- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 01:45 PM
We have a Catalog Item with a Multi-Row Variable Set (MRVS) that has two fields:
- Bucket
- Keywords
The Bucket field is a Reference field to a list of values we have in a table.
The Keywords field is a String field.
One of the options for the Bucket field is "New". If they select "New" at least once when populating the MRVS, we need a new Variable to pop-up that asks "What would you like the name of the new Bucket to be?".
Typically, we would control this with a Catalog UI Policy. But I don't see any option to check the value of a MRVS entry in the Catalog Conditions of Catalog UI Policy (i.e. "Bucket contains New"). I am guessing that we might need to script this out.
What is the best way to check the entries of a completed MRVS to look for a specific value in a field of that MRVS, and only expose that other question when that condition is satisfied?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 05:24 PM
Triggering a Catalog Item script when a MRVS changes can be tricky as there is nothing watching for rows to be added or edited, but in this case you can do it from the MRVS. I'm assuming you have the 'bucket name' variable in the Catalog Item hidden when the form loads, so to show it if 'New' is selected in any row, you can use a script like this that applies to the MRVS. It will trigger when a row is added or edited:
function onSubmit() {
if (g_form.getValue('v_bucket') == 'sys_id of New record') {
if (this) { //Service Portal method
this.cat_g_form.setVisible('v_bucket_name', true);
} else { //native UI method
parent.g_form.setVisible('v_bucket_name', true);
}
}
}
Where 'v_bucket' is the name of the MRVS reference variable, and 'v_bucket_name' is the name of the Catalog Item variable. You can also add similar lines to setMandatory if needed. If you are using Service Portal / ESC, you will also need this script that applies to the Catalog Item:
function onLoad() {
if (this) {//we only need to do this for Service Portal
//We need to make the g_form object for the parent item available from the MRVS window
this.cat_g_form = g_form;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 08:02 AM
Brad,
For some reason this is not working for me.
First, a few preliminaries:
1. The name of the reference field in the MRVS is "bucket"
2. The name of the related field on the parent Catalog Item is "new_bucket_name".
3. The sys_id of the "New" selection in the underlying reference table is: "a4e9ffc52be8a210bf1cf17dce91bfd8"
So, first I have this Catalog Client Script on the parent Catalog Item in order to hide the field on load:
And then here are the two Catalog Client Scripts that I added to the MRVS:
However, when I test it out and add a row in the MRVS that has "New" selected in the Bucket field, it does not expose the field on the Catalog Item.
What am I doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 08:07 AM
The onLoad script I shared needs to apply to the Catalog Item, not the Variable Set. Since you already have one you can just add the if block to the existing script that is hiding the variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 08:27 AM
Thank you! That fixed it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 08:29 PM
So based on when row is added you need to show another variable outside MRVS on your form directly?
If yes then there is no straight way for this
you can check these links on how they have detected if row is added/removed and based on that show/hide the outside variable
MRVS detect when a row is removed or deleted
Widget that reacts to onChange event of Variable
Also check solution shared by @Brad Bowman
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader