- 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 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 09:24 PM
Hello @Murthy Ch ,
Where should I run this script—in the Variable Set or the Catalog Item?
I tried using it in the Catalog Item to setDisplay and setVisible, but it didn't work. Also, I have a doubt: if we write this inside an MRVS, getParameterValue will return the Variable Set's sys_id. So, when we compare it with the Catalog Item's sys_id, it will obviously return false.
If we write this in the Catalog Item, what is the purpose of checking those conditions? Since this client script runs only for this specific Catalog Item, wouldn’t the check be redundant?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 09:30 PM
Hi @Aditya02
You need to write the script in MRVS catalog client script (in variable set)
The getParamterValue is the function which returns catalog item sys_id. So, I believe it works and tested in my PDI before sharing the code. Keep me posted if you have any questions.
Happy to answer
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 09:48 PM
Hello @Murthy Ch ,
I tried this, but i am getting null as sys_id. and i am seeing that unescape is deprecated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2025 10:05 PM
you won't know the URL within MRVS client script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader