- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2022 12:48 PM
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;
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2022 11:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 11:07 AM
Hello ,
In this case please call a script include in the reference qualifier using the below syntax
javascript:new your_scriptinclude_name().your _function_name(pass your choice value as paramter);
and in your script include you can write your code for IF statement and return true or false
Please mark this helpful if this answers your question.
Thanks
Mohith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2024 08:03 PM
you can also use a client script if you want to be a bit more dynamic:
this article worked for me:
How to modify Reference Qualifiers with Catalog Client Scripts – ServiceNow – ServiceNow Think (word...
and this is the onChange client script: