How to default a catalog variable to visible = false

johnpaulbrazill
Kilo Contributor

All,

I would like to pose a question about catalog variables, those in variable sets specifically.

The scenario is the development of variable sets that are shared among many catalog items that undergo modifications.

Example: I have variable sets called Requested By and Requested For, each of which have Name, Email, Phone. For some catalog items, additional information is necessary such as Alternate Contact Information, Manager, etc. The desire is to have these variables incorporated into the variable set but are only visible if explicitly set in certain catalog items. Otherwise we get into a situation where a new variable is introduced in the set and we have to go into any other catalog items and write a ui policy or catalog client script to hide it. 

Lacking the feature of setting the default visibility on the variable definition (like you can with mandatory), what is the best way of approaching this?

3 REPLIES 3

Elijah Aromola
Mega Sage

You can write a client script that does this:

function onLoad() {
  // only sets if there is no value in the variable.
  if(!g_form.getValue('variable_name') {
     g_form.setValue('variable_name');
  }
}

Mike Patel
Tera Sage

Create UI policy that is applied to variable set to set visible to false and have order of 50.

Than for each catalog item create UI policy to show those variables and set order to 100.

Michael Jones -
Giga Sage

Create a Catalog UI Policy on the variable set itself with no condition, on load and include UI actions to hide the fields you don't want to see. Set them at order 100.

Then one each catalog item, add Catalog UI Policies and Actions to display those fields you want (either by default with no condition, or with a condition) and set them to an order of 200. 

They will be hidden by default, but display only on items where you have a second set of rules that happen after order 100 to display them. 

If this was helpful, or correct, please remember to be kind and click appropriately! 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!