- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 10:31 AM
I have a Catalog Client Script that is used by some Catalog Items and some Order Guides. What I would like to know is if I can find out if the script is being called from within a particular order guide.
I tried using g_form and referencing the name of the form...nope.
Is there a way that I can, through the script, find out if it's being run from within a Client Script?
Thanks,
Eric
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 02:32 PM
There are a couple of hidden input fields that will help you out here. Add the following line of code to an onLoad catalog client script on both your Order Guide and an actual Catalog Item:
g_form.addInfoMessage("sysparm_guide = " + $("sysparm_guide").value + "<br/>" + "current_item = " + $("current_item").value + "<br/>" + "on the order guide itself = " + ($("sysparm_guide").value == $("current_item").value));
It will display the sys_ids of the Order Guide (sysparm_guide) and the Catalog Item (current_item). You will be on the Order Guide's start page if both sys_ids are the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 12:08 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 12:21 PM
Class field in Catalog Item can provide you if the catalog client script is on Catalog Item or Record Producer or Order Guide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 01:40 PM
I don't think I made it clear as to what I'm trying to do.
I have a Catalog Client Script that is run from Catalog Items and from an Order Guide. I only want to set a field as writeable if the script is being run from a particular order guide.
For instance, in the script below, I only want to allow users with the itil_lite role and that works, but I only want this to run when it's on a particular order guide. I have added the g_orderguide.name() which I know isn't a call, but I want to be able to find out where this code is being run before I allow the user to update a field. In this case, the code is being run from an orderguide named "Terminate" then I'll allow the user to read, if it's anything else, then set to read only. I hope that's a little more clear.
var uRole=g_user.hasRole('itil_lite');
var isOrderGuide = g_orderguide.name();
if (isOrderGuide='Terminate'){
if (uRole==true)
g_form.setReadOnly('manager_name', false);
}
else{
g_form.setReadOnly('manager_name', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 02:32 PM
There are a couple of hidden input fields that will help you out here. Add the following line of code to an onLoad catalog client script on both your Order Guide and an actual Catalog Item:
g_form.addInfoMessage("sysparm_guide = " + $("sysparm_guide").value + "<br/>" + "current_item = " + $("current_item").value + "<br/>" + "on the order guide itself = " + ($("sysparm_guide").value == $("current_item").value));
It will display the sys_ids of the Order Guide (sysparm_guide) and the Catalog Item (current_item). You will be on the Order Guide's start page if both sys_ids are the same.