Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Hide Catalog Variables Based on Order Guide (Client Script Approach)

venkat ajay
Tera Contributor

 

Hi Community 👋,

I wanted to share a simple and effective approach to show/hide catalog variables based on a specific Order Guide.

🔍 Use Case

  • The same Catalog Item is used in multiple Order Guides

  • Certain variables should be hidden only for one specific Order Guide

  • The same variables should remain visible for all other Order Guides

UI Policies were not sufficient in this case, so I used a Catalog Client Script.


🛠 Solution Overview

  • Detect whether the form is opened via an Order Guide

  • Read the Order Guide sys_id from the URL (sysparm_guide)

  • Conditionally hide or show variables using g_form.setDisplay()


Sample Client Script

 

 
var guide = g_service_catalog.isOrderGuide();
var url = top.location.href;
var orderGuideSysId;
// Get Order Guide sys_id from URL (Native UI)
orderGuideSysId = new URLSearchParams(url).get("sysparm_guide");
if (orderGuideSysId == '<order guide sys id>') {
// Hide variables for this specific Order Guide
g_form.setDisplay('<variable name>, false);
g_form.setDisplay('<variable name>', false); }
else {
// Show variables for all other Order Guides
g_form.setDisplay('<variable name>', true);
g_form.setDisplay('<variable name>', true);
}

Notes

  • Always verify the sysparm_guide value from the browser URL

  • Test in both Native UI and Service Portal (URL handling may differ)

  • For multiple Order Guides, you can extend this logic using an array of sys_ids


💬 Final Thoughts

I hope this helps anyone facing similar Order Guide–specific requirements.
Please feel free to share improvements or alternative approaches.

 

Thanks! 😊

Venkat Ajay P

 

 

0 REPLIES 0