- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2016 12:42 PM
In a catalog client script, how would I check and act on something depending on what order guide is being used for a specific item?
Example:
I have a catalog Item "My Item" with fields "field_1", "field_2", and "field_3".
I also have two Order Guides: "OG_1" and "OG_2", that each are set to include "My Item" in each order guide.
How would I write a catalog client script to hide "field_2" only when being viewed from "OG_2"?
On the client script form, I have tried specifying the Order Guide ("OG_2") in the Catalog Item field, but when I did that, the script does not act on the field. When I switch the Catalog Item field on the Client Script form back to "My Item", it works fine. However, my entire goal is to be able to script if based off of which order guide is used.
function onLoad() {
g_form.setDisplay('field_2',false);
}
Any feedback would be greatly appreciated.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 06:49 AM
I've been able to do this in a client script with $('current_guide'); it returns the sys_id of the guide being used.
In my case, I used it to check for a specific guide, and when this item was used in that particular guide, it ran through an array of variables to hide them.
function onLoad() {
var item = $("current_guide");
varList = [MY_VAR_1,MY_VAR_2,MY_VAR_3];
if (item=='9d91b08a4f84e240abd9b5e18110c7a6')
return;
else {
for (var i=0;i<varList.length;i++) {
hideThem(varList[i]);
}
}
}
function hideThem(name) {
g_form.setMandatory(name,'false');
g_form.setVisible(name,'false');
}
$("current_item"); has also been very useful for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2016 12:51 PM
Hi Simon, you can do this using a catalog UI policy which responds to the value of a specific variable which value could be different within each order guide.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2016 12:53 PM
I hope this helps . Please let me know if you have any further questions.
Thanks,
Berny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2016 05:27 PM
Hi Simon,
Here are some details on how I have accomplished this in the past.
1) Create a new Variable Set and name it whatever you please
2) In that Variable Set, create a new Select Box variable named Request Source[request_source].
2a) Create a choice of Catalog Item[catalog_item]
2b) Create a choice of Order Guide 1[order_guide_1]
2c) Create a choice of Order Guide 2[order_guide_2]
2d) Set the default value to catalog_item
3) On any items used in either Order Guide, add the Variable Set created in step 1
4) On both Order Guides, add the Variable Set created in step 1
5) On Order Guide 1, create a Client script, which runs On Load, and sets the value of request_source to order_guide_1
6) On Order Guide 2, create a Client script, which runs On Load, and sets the value of request_source to order_guide_2
7) Set Cascade Variables to true on both Order Guides
In doing this, when one of the Order Guides loads, the request_source variable will be set to the value for that Order Guide. When Choose Options is selected, the value of request_source will then be copied from the Describe Needs page to each item. From here, UI Policies can be used on individual items to check what the value of request_source is and act accordingly.
You can also access variables in your catalog item workflows, so this information can be used there as well.
Enjoy!
-Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2016 07:00 AM
Thanks Robert!
I've tried implementing your solution, but it doesn't seem to be working for me. Annoying because I believe the script should be quite simple, but just isn't acting on it.
My test catalog item:
"Number" [number]
Order Guides
North America [north_america]
Europe [europe]
As you said, I created a variable set containing a choice list [request_source] of three choices, Catalog Item [catalog_item], North America [north_america], and Europe [europe]. I've added this variable set to both Order Guides, and the "Number" catalog item. Set the variables to cascade, and confirmed that the cascading is working. So, as far as the main driving point of your solution, we're all good.
However, for some reason my OnLoad Catalog Client Script isn't working. I have not really scripted with variable sets in the past, is there something special that needs to be done to reference them inside the variable set?
Here's my script that isn't working:
function onLoad() {
var guide = g_form.getValue(request_source);
if (guide == 'north_america') {
g_form.setValue('two','test'); //the "Number" catalog item has variables: "one","two","three"
g_form.setDisplay('three','false');
}
}