- 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-26-2025 02:07 PM
Hello @jmiskey
Please try below in on change catalog client script -
var isNewSelected = false;
var allRows = gForm.getValue('<MRVS_VARIABLE_NAME>');
if (allRows) {
var rows = JSON.parse(allRows);
rows.forEach(function(row) {
if (row.Bucket == "New") {
isNewSelected = true;
}
});
}
gForm.setDisplay('<NEW_BUCKET_VARIABLE>', isNewSelected);
Please let me know if you stuck somewhere.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 02:20 PM
Hello @jmiskey
Well just wanted to add, did you also try the Catalog UI policy in variable set itself ?
It will make the variables in the MRVS delectable from UI policy.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 04:24 PM
If I try either of those things, it puts the Catalog Client Script or Catalog UI Policy right in the MRVS. The issue is this other field is OUTSIDE of the MRVS, in the main Catalog Item. And it doesn't appear you can reference that main Catalog Item variable from inside the MRVS.
- 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;
}
}