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

Thank you! 

I would appreciate any help you could give.

Allen Andreas
Administrator
Administrator

Hi,

Technically, you can use an if statement as using the "javascript:" prefix enables that field to accept JavaScript however, if it's a bit more complex, then yes, a Script Include may be better suited.

So use if statement though you'd use something like:

javascript:var query; if (current.variables.variable_name = 'x') { query="encodedQuery_here"; } else { query="encodedQuery2_here"; } query;

You can also use current.field_name if this doesn't involve variables. The above is an example. Hopefully you can take it from here?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Sorry I am not quite getting it in regards to how to get this written. I need it to work in such a way as "current.variables.business_unit_aws = DBA-misc" no filters get applied else the filter below gets applied.

 

Current reference qualifier:

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

 

 

Hello,

I see you've found a correct answer. It was hopeful that displaying that you can in fact use if statements and the like, would help guide you all the way.

In any case, glad it's resolved.

If my reply above helped provide any guidance, please mark it as Helpful.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!