- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2021 03:29 AM
I wanted to get the sys id of the order guide using client catalog script. I have created one maintain item and added one variable of type list collector. I have added this into order guide. Same maintain item will be used in multiple order guides. I need to show or hide the option based on order guide. I have created client catalog script for this maintain item and included following snippet, but this is always giving sys id of the maintain item not the order guide's.
var currentItem = g_form.getUniqueValue();
How to get order guide sys id in service portal?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2021 04:17 AM
Hi,
nope.
for both native and portal you can get the URL parameter value in the onLoad client script and get the order guide sys_id
For native URL looks like this - https://instanceName.service-now.com/com.glideapp.servicecatalog_cat_item_guide_view.do?v=1&sysparm_initial=true&sysparm_guide=6690750f4f7b4200086eeed18110c761
For portal URL looks like this - https://instanceName.service-now.com/sp?id=sc_cat_item_guide&sys_id=6690750f4f7b4200086eeed18110c761
For native - get sysparm_guide
For portal - get sys_id
function onLoad() {
//Type appropriate comment here, and begin script below
var url = top.location.href;
var orderGuideSysId;
if(window == null){
// for portal
orderGuideSysId = new URLSearchParams(url).get("sys_id");
}
else{
// for native
orderGuideSysId = new URLSearchParams(url).get("sysparm_guide");
}
alert(orderGuideSysId);
}
Regards
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
‎06-25-2021 04:21 AM
Hi Mihir,
for both native and portal you can get the URL parameter value in the onLoad client script and get the order guide sys_id
For native URL looks like this - https://instanceName.service-now.com/com.glideapp.servicecatalog_cat_item_guide_view.do?v=1&sysparm_initial=true&sysparm_guide=6690750f4f7b4200086eeed18110c761
For portal URL looks like this - https://instanceName.service-now.com/sp?id=sc_cat_item_guide&sys_id=6690750f4f7b4200086eeed18110c761
For native - get sysparm_guide
For portal - get sys_id
function onLoad() {
//Type appropriate comment here, and begin script below
var url = top.location.href;
var orderGuideSysId;
if(window == null){
// for portal
orderGuideSysId = new URLSearchParams(url).get("sys_id");
}
else{
// for native
orderGuideSysId = new URLSearchParams(url).get("sysparm_guide");
}
alert(orderGuideSysId);
}
Regards
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
‎07-22-2021 03:34 AM
Hi
I am trying to display variable set depeneding on choice variable only when it is order guide and used above script. It is not working in instance home, but working when we open in new tab. Could you please help?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2021 03:53 AM
Please check by adding alert and check any browser console errors
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader