- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 06:22 PM
Hi Community,
I was trying to hide an option in a reference field based on the selection on another field but I can't seem to make it work. I have seen a couple of similar question here in community but the solution that works for them does not seem to work when I tried it.
Requirement:
When country = Singapore, category shoould show Recruitment, all other countries should not show the Recruitment category.
My script Include:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 08:37 PM
Hi @Ramel
Ok lets do vice-versa...have a try once.
javascript:
var query;
if (current.variables.u_country != 'SINGAPORE'){
query = "u_available_forISNOTEMPTY^u_name!=Recruitment/Onboarding";
}
else {
query = "u_available_forISNOTEMPTY";
}
I have checked in my PDI its working as expected....!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 06:55 PM - edited 09-14-2023 06:56 PM
Hello @Ramel
Can you please let us know what is the type of "category" field..?
I guess its reference field.
Instead of writing script include and all can you try this reference qualifier
javascript:
if (current.variables.u_country == 'sys id of Singapore'){
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 07:03 PM
Thanks for the response.
Correct, category field is a reference field. While my country is a lookup select type.
I have tried adding the script in the reference qualifier instead of using the script include but also did not work.
I can still see the recruitment in the option when location is not Singapore.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 07:14 PM
Is it catalog item..??
Also can you provide screenshot of "country" filed or variable form.
I want to see type specifications for that variable/field
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 07:20 PM - edited 09-14-2023 07:21 PM
It is a record producer. Country field is a lookup select box. It is looking up the record in the core_country table and only showing specific list of countries as defined in the reference qualifier.
Regards,