- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 08:01 AM
Hi,
I have a variable set which is being used in three catalog items. There is a client script in the variable set, that I want to disable for one of the catalog items. What script can I write so that the code does not work for one of the catalog items?
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 08:08 AM
You could try adding an if statement around your block of code along the lines of:
if(current != <catalog_sys_id>){
//your code block here
}
The <catalog_sys_id> would be the sys_id for the catalog item you want to disable this code for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 08:08 AM
You could try adding an if statement around your block of code along the lines of:
if(current != <catalog_sys_id>){
//your code block here
}
The <catalog_sys_id> would be the sys_id for the catalog item you want to disable this code for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 08:10 AM
Hi Prabh,
you can do following:
1) in the onLoad catalog client script get the URL
2) determine the sys id of the catalog item from the url parameter sysparm_id
if it is the one you are looking for then make all variables readonly
function onLoad(){
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
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-14-2019 08:14 AM
get the sys_id of the catalog item from the url and as Brian mentioned restrict the code from running if the sys_id matches to the one you are looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2019 08:33 AM
Hi Prabh,
Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader