- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 02:32 AM
Hello,
There is a catalog client script written on a variable set that I've created on. And, have used the variable set in the catalog item as well as in the order guide.
Now the actual requirement is, I want the catalog client script to run only on the standalone catalog item form having the variable set and not on the order guide form (even if the order guide has that particular item in it) .
Could someone help me achieve this, please ? Thanks in Advance!!
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 03:39 AM
Can you try this for native UI:
$("sysparm_guide").value
for example:
if($("sysparm_guide").value){
return;
}
based on:
Or try:
g_request.getParameter('sysparm_guide')
Example:
if(g_request.getParameter('sysparm_guide')){
return;
}
Based on:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 02:36 AM
HI,
if this is part of portal then you can use the below
g_service_catalog
function onLoad() {
if (window) // if CMS don't run this
return;
// g_service_catalog api for Service Portal and Mobile
var isOrderGuide = g_service_catalog.isOrderGuide();
g_form.setValue("is_order_guide", isOrderGuide ? "Yes!" : "Nope :(");
}
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 03:30 AM
Hello
Thanks a lot!
This is working absolutely fine for me in the Portal. However, I'd also need a way to achieve this in the Main UI page (UI type - Desktop, Service Portal and All) of ServiceNow.
If there's a way out for this, Could you paste me your code for both Portal and Main UI page ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 03:34 AM
Can't thing of a smart way on native ui.
May be you can keep some hidden variable(on the catalog) that will be true or false depending whether or not this catalog is part of order guide or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 02:43 AM
Few additions to Anurag's comment.
Instead of if(window) return set the UI Type to Mobile/Service Portal.
To not run the script for order guides use the g_service_catalog like this at the start of your script:
if(g_service_catalog.isOrderGuide()){
return;
}
So not set a value. But return, which stops the script from further executing.
Please reference below for the g_service_catalog.isOrderGuide():