How to check current item is OrderGuide in Client Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 10:29 PM
Hi.
I want to make a field display true in a few OrderGuides.
So i want to make onLoad script that check type of catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 10:43 PM
Hi @Jaeik Lee ,
To check if the current catalog item is an Order Guide in a client script, you can use the g_form object to get the catalog item's type, and then compare it to the value of the Order Guide constant.
function onLoad() {
var item_type = g_form.getTableName();
var ORDER_GUIDE_TYPE = "sc_cat_item_guide"; // replace with the actual value of the Order Guide type constant
if (item_type == ORDER_GUIDE_TYPE) {
g_form.setDisplay('field_name', true); // replace 'field_name' with the actual name of your field
} else {
g_form.setDisplay('field_name', false); // hide the field for other types of catalog items
}
}
Regards,
Shravan
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 03:51 AM
Hi,
As of today, the above provided method doesn't work.
Instead @Jaeik Lee , use method g_service_catalog.isOrderGuide(), I've tested it and it works (it returns true/false whether you are on a Catalog Item or an Order Guide.
OnLoad Client Script:
function onLoad() {
alert("OG: " + g_service_catalog.isOrderGuide());
}
Regards,
Simone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2025 09:46 PM
How exactly did you test that, as it does not work on the actual order guide only the children of that order guide. Because in my testing in the order guide itself, it's returns false.
Another wonder of the SN devs and their coding ability. Imagine removing the table check only to have this nerf'd method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 08:59 PM
Hi @Sai Shravan
i need similar requirment , can you please let me know what is order type constant here?