Need Help on catalog client script logic is not working for all catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2025 04:05 AM
Hi Team,
I have a requirement, where on the basis of location change , one question is visible(type -select option) .This question having 7 options,In 2 catalog I wanted to show all 5 option and in other wanted to Hide all 5 option
I tried solution given in below link
http://servicenow.com/community/cmdb-forum/need-help-on-catalog-client-script/m-p/3248701/page/2#
However seems this code is working in some scenario and not working for other catalogs
Below is the on change script on location change
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var url1 = window.location.href;
var url=top.location.href;
//When catalog is search from serviceportal//var url = top.location.href;
//When catalog is search from direct link / var url1=window.location.href
if (url.indexOf('1265352c971ce1582519de24a253af88') > -1 || url.indexOf('55b7b9a0979ce1582519de24a253afc2') > -1)
{
g_form.addOption('deliver_at', 'A');
g_form.addOption('deliver_at', 'B');
g_form.addOption('deliver_at', 'C');
g_form.addOption('deliver_at', 'D');
g_form.addOption('deliver_at', 'E');
g_form.addOption('deliver_at', 'F');
}
else if (url1.indexOf('target/com.glideapp.servicecatalog_cat_item_view')>-1 && url.indexOf('1265352c971ce1582519de24a253af88')>-1 ||url1.indexOf('target/com.glideapp.servicecatalog_cat_item_view')>-1 && url.indexOf('55b7b9a0979ce1582519de24a253afc2')>-1
{
g_form.addOption('deliver_at', 'A');
g_form.addOption('deliver_at', 'B');
g_form.addOption('deliver_at', 'C');
g_form.addOption('deliver_at', 'D');
g_form.addOption('deliver_at', 'E');
g_form.addOption('deliver_at', 'F');
}
else {
g_form.removeOption('deliver_at', 'A');
g_form.removeOption('deliver_at', 'B');
g_form.removeOption('deliver_at', 'C);
g_form.removeOption('deliver_at', 'D');
g_form.removeOption('deliver_at', 'E');
g_form.removeOption('deliver_at', 'F');
}}
UI Type-"All"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2025 07:38 AM
the sysId 1265352c971ce1582519de24a253af88 is found in the direct URL as well
you didn't use the script I shared.
the script I gave uses top.location.href and should work in both native (direct URL) and portal
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var url = top.location.href; // this will always give you the url
if (url.indexOf('1265352c971ce1582519de24a253af88') > -1 || url.indexOf('55b7b9a0979ce1582519de24a253afc2') > -1) {
g_form.addOption('deliver_at', 'A');
g_form.addOption('deliver_at', 'B');
g_form.addOption('deliver_at', 'C');
g_form.addOption('deliver_at', 'D');
g_form.addOption('deliver_at', 'E');
g_form.addOption('deliver_at', 'F');
} else {
g_form.removeOption('deliver_at', 'A');
g_form.removeOption('deliver_at', 'B');
g_form.removeOption('deliver_at', 'C');
g_form.removeOption('deliver_at', 'D');
g_form.removeOption('deliver_at', 'E');
g_form.removeOption('deliver_at', 'F');
}
}
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
05-04-2025 08:25 AM
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
05-05-2025 11:16 AM
Hi Ankur
above solution is not working for now/nav/ui/classic/params/target/com.glideapp.servicecatalog_cat_item_view.do view ,it is only working for serviceportal
From maintain item also if you try it above solution will not work
