- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 12:54 PM
Hi guys,
I'm struggling to achieve the following: based on a variable value change (select box variable) in a catalog item (located directly on the catalog item), I need to display or hide another variable inside of one MRVS.
Is that possible?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 01:21 PM - edited ‎07-01-2025 01:22 PM
Hi @Dennis17 ,
Try creating a duplicate hidden (select box) variable in the MRVS. Use a onLoad client script(in the MRVS) to populate its value in the MRVS. Once this is done you can use UI policies on the MRVS to conditionally show the fields. Sharing onLoad script for your reference.
function onLoad() {
//Type appropriate comment here, and begin script below
var type = g_service_catalog.parent.getValue("Variable on the catalog item"); //replace with variable on the catalog item
g_form.setValue("Variable on the MRVS", type); //replace with variable on MRVS
}
This has worked for me in the past. Hope this helps.
Please mark this response as correct or helpful if it assisted you with your question.
Thanks,
Rishi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 11:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 11:24 PM
there is a trick to access outside variable within onLoad or onChange catalog client script which applies on MRVS
You can access the outside variable using this syntax, it works in both native + portal
var variableValue = g_service_catalog.parent.getValue("outsideVariableName");
I wrote a blog as well for this
Access value of catalog item variable within MRVS client script
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