- 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
‎07-07-2016 07:59 AM
Hi Simon,
A couple of things to point out here, on line 2 when you call request_source, I would recommend adding quotes around this. Additionally, it is good practice to use the syntax of 'variables.request_source', rather than just 'request_source'. You can read more on that topic in the Creating a Catalog Client Script article. I am not sure what your variable type is for the variable two, but if you have that as a string of some sort you should be fine with what you have.
Enjoy!
-Robert Chrystie
- 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