- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 08:39 PM
I want to Hide a Variable (state_name) which exists in a Multi row Variable set for a specific catalog item. I've tried set display, setvisible by writing a onload and ui policy scripts. but it wo'nt worked. Any one have any idea to hide variable in MRVS for specific cat item.. this requirement is little bit urgent..
Thank you in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 08:57 PM
You can try something like below in MRVS client script:
function onLoad() {
//Type appropriate comment here, and begin script below
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
var catSysId = getParameterValue('sys_id');
if (catSysId == "7198552237b1300054b6a3549dbe5dea") { //replace with your cat item sys_id and variable name
g_form.setDisplay('device_type', false);
}
}
(=tested)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 10:49 PM
Hello @Murthy Ch ,
Thank you for providing me with this script. It works well on the Service Portal, which is great! If there’s a way to make it work on the Native UI as well, that would be even better.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 10:49 PM
are you able to access the browser URL inside client script of MRVS?
I tried and it didn't work for me.
I shared 1 workaround for the same below.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 09:37 PM
So based on outside variable value you need to show/hide the MRVS variable when MRVS add row is opened?
if yes then you can use onChange of onLoad which Applies to MRVS and your variable and use this to access the outside variable value
var value = g_service_catalog.parent.getValue("variableName"); // give here the outside variable name here
I have created blog for the same
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 09:43 PM
Hi @Ankur Bawiskar ,
Here I don't want to hide variable inside MRVS by outside variable value.. I just want to hide the variable which is inside the MRVS by loading the form itself for only particular catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 10:02 PM
is this MRVS in multiple catalog items?
if yes then do this.
1) create a hidden text variable and place it at the end of the form i.e. highest order in your single catalog item
2) then you can use onLoad catalog client script which runs on catalog item and get the sysId of that catalog item from URL and store that in hidden variable and hide it
3) then use onLoad catalog client script on MRVS and use this syntax to access the outside variable value and you will know which catalog item it is and then hide
var catItemSysId = g_service_catalog.parent.getValue("hiddenVariable"); // give here the outside variable name here
if(catItemSysId = 'your sysId'){
g_form.setDisplay('variableName', false); // mrvs variable name you want to hide
}
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