current_item and sysparam_guide variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 03:30 AM
Below script is from ITSM Implementation course Lab. 4.3.3. and I can not understand nor find any explanation of what are current_item and sysparam_guide variables and what is the role of the following IF section.
To give you more inputs the variables which are set to be invisible are included in order guide in variable set and also in variable set in catalog item placed in rule base. So they are duplicated in the form. Cascade variables are enabled in order guide.
I was thinking that without declaration of the variables and IF section it will work the same (as if section returns nothing) but it is not the case. Variables delivery_location, office, home_address disappear from the order guide completely.
function onLoad() {
//Hide variables common to the Order Guide and included Items.
var item = $("current_item");
var guide = $("sysparm_guide");
if (((item != null && guide != null) || (item == null && guide == null)) && item.value == guide.value)
return;
g_form.setVisible('delivery_location', false);
g_form.setVisible('office', false);
g_form.setVisible('home_address', false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 04:11 AM - edited ‎04-27-2025 04:15 AM
Hi @thebananek
$('current_item') is used in client scripts to retrieve the sys_id of the currently displayed catalog item, if you are using order guide.
$('syspatm_guide') will give you the currently used order guide sys_id.
Support article:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0814750
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 03:06 PM - edited ‎04-27-2025 03:07 PM
Awesome the same code used there in the KB. So it looks like a template. But do you understand what that part exactly does? Especially what is the role of the IF condition?
var item = $("current_item");
var guide =$("sysparm_guide");
if(item != null && guide != null && item.value == guide.value)
return;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 05:56 AM
Hello @thebananek
Current item and Current guide as the name says.
But what were you trying to achieve , where you are saying its completely removing from the guide itself ?
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2025 03:01 PM - edited ‎04-27-2025 03:08 PM
I mean that fields delivery_location, office, home_address disappear from the order guide form completely when this part is removed from the script:
var item = $("current_item");
var guide = $("sysparm_guide");
if (((item != null && guide != null) || (item == null && guide == null)) && item.value == guide.value)
return;
I don't get why this happen.