- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 01:59 AM - edited 04-25-2025 02:22 AM
Hi Team,
There is one variable A- type -select box in the catalog .This select box have option 1,option2,otions3,option4. This Catalog variable is part of variable set and variable set is configure in multiple catalog ,Now I have added 2 more option in this variable A
Now my requirement is the newly added options should be visible only in 2 catalog ,How I can achieve this using client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2025 07:46 PM
Hope you are doing good.
Did my reply answer your question?
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
04-25-2025 02:11 AM
simply use onLoad catalog client script which Applies to your Variable set
Then search in URL the 2 catalog item sysIds
If it's present then show those options
If not then remove those 2 options
function onLoad() {
var url = top.location.href;
if (url.indexOf('catalogItemSysId1') > -1 || url.indexOf('catalogItemSysId2') > -1) {
// show and don't do anything
} else {
g_form.removeOptions('variableA', 'choiceValue1');
g_form.removeOptions('variableA', 'choiceValue2');
}
}
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
04-25-2025 03:04 AM - edited 04-25-2025 03:56 AM
Hi Ankur,
Thankyou for the reply ,You suggestion helped ,in my case variable A is depend on location hence i have written a on change script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 03:24 AM
if that variable is shown based on some other variable then ensure you write that in the correct onChange catalog client script/
You never told this in your original question.
The script I shared will work fine as per your original question, you can always enhance it.
I believe I have answered and given a logic on how it can be done.
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
04-27-2025 07:46 PM
Hope you are doing good.
Did my reply answer your question?
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