How to modify a reference qualifier for a Catalog Item variable?

Bill7
Mega Expert

Currently we use a reference qualifier to determine what fields are available in a reference field. I have not found where I can do the equivalent to an If statement for it.  This filter works for every choice except one choice.  If they pick that choice we do not want to filter at all.  Any idea how to handle this?

 

Current reference qualifier: javascript: 'u_kemper_business_unit=' + current.variables.business_unit_aws+'^environment='+current.variables.environment_ref_aws;

1 ACCEPTED SOLUTION

You can try this as your reference qualifier:

javascript:(function() {  if (current.variables.business_unit_aws == 'DBA-misc') {return;} else { return ('u_kemper_business_unit=' + current.variables.business_unit_aws+'^environment='+current.variables.environment_ref_aws);} })();

By returning nothing for the DBA-misc statement it means we don't have anything for our reference qualifier, which is what you're looking for. 

A Script Include could be used as well. The Script Include would be easer to read (the above is one giant line) and reusable. 

I would probably just do the self-executing function myself if I wasn't needing to reuse it because what you are asking for is pretty straight forward. I would draw the line at having to do a GlideRecord lookup or something more complicated just because it's hard to read the code all on one line.

I have tested the above using other variables on a form in my instance. I have not tested it using current.variables though. I am assuming it would work, but that's the part I'll let you test. If it doesn't we can do it in a Script Include.

View solution in original post

11 REPLIES 11

maroon_byte
Mega Sage

Call script include instead... in the script include, pass the choice. In the script include, use gliderecord and put addquery() conditionally.

javascript: new YOUR_SCRIPT_INCLUDE().YOUR_FUNCTION(choice_value);

Hope it helps.

 

TrevorK
Kilo Sage

We often just use a Script Include for our Reference Qualifier functions. You would pass in the values and your Script Include would process it. This ends up looking something like this:

javascript: new x_nait3_procur_cyl.CylindersHelper().getToBeReturnedOrders(current.variables.shipping_account)

One other way you can do a reference qualifier is to have a self executing function right inside it. I think the better practice would be to have it in the Script Include, however something like this is possible:

javascript:(function() { return 'sys_scope=' + current.sys_scope;})();

 

Would either of those meet your use case? I can help with writing it if you need help, but I need a bit more to go on for what you're looking to change from your current one.

Currently we want the reference qualifier to work for every choice except one.

We want the the below reference qualifier to trigger except when current.variables.business_unit_aws = DBA-misc  when that is true we want to not trigger any filters for our choices.

Current reference qualifier: javascript: 'u_kemper_business_unit=' + current.variables.business_unit_aws+'^environment='+current.variables.environment_ref_aws;

You can try this as your reference qualifier:

javascript:(function() {  if (current.variables.business_unit_aws == 'DBA-misc') {return;} else { return ('u_kemper_business_unit=' + current.variables.business_unit_aws+'^environment='+current.variables.environment_ref_aws);} })();

By returning nothing for the DBA-misc statement it means we don't have anything for our reference qualifier, which is what you're looking for. 

A Script Include could be used as well. The Script Include would be easer to read (the above is one giant line) and reusable. 

I would probably just do the self-executing function myself if I wasn't needing to reuse it because what you are asking for is pretty straight forward. I would draw the line at having to do a GlideRecord lookup or something more complicated just because it's hard to read the code all on one line.

I have tested the above using other variables on a form in my instance. I have not tested it using current.variables though. I am assuming it would work, but that's the part I'll let you test. If it doesn't we can do it in a Script Include.