How to make variable in MRVS hide/visible based on dropdown variable outside of MRVS in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
I have requirement to make a variable in MRVS to be hidden based on a selection in a drop down field which is outside of MRVS in a catalog item. How can I achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hi @nagakarthik0721 ,
To achieve this, you can use a Onchange Catalog Client Script with the g_form to dynamically control the visibility of MRVS variables based on the value of a dropdown variable outside the MRVS.....
Variable Name: Select the dropdown variable that will control the visibility.
UI Type: Choose All or specify as required.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') return;
// Define the MRVS variable to show/hide
var mrvsVariable = 'your_mrvs_variable_name'; // Replace with your MRVS variable name
// Show or hide the MRVS variable based on the dropdown value
var shouldShow = (newValue === 'your_condition_value'); // Replace with your condition value
g_form.setDisplay(mrvsVariable, shouldShow);
}
Replace 'your_mrvs_variable_name' with the actual name of the MRVS variable and 'your_condition_value' with the value from the dropdown that should trigger the visibility change.
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago - last edited 6 hours ago
Try below :
var itemVal =g_service_catalog.parent.getValue(“cat_var_name”);
if (itemVal==“choice value”)
g_form.setVisible(“mrvs var”,false);
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
@RaghavSh , I hope you are suggesting to write a client script within MRVS, I need the field in MRVS to be hidden whenever change happened to field outside MRVS.
If I create a on change client script as you suggested on MRVS, I am not able to select the field outside MRVS in variable name in client script as it will only show variables in MRVS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
In this case you can directly write onchange client script on catalog level variable and make mrvs variable hidden.
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand