How to exclude the current user in the reference field.

Kvb Kiran
Tera Contributor

There is a catalog item.
It contains two reference field where we can choose users.
Second reference field only appears after filling the first reference field with a user.

The requirement: the user selected in the first reference should not appear in the second reference field.

 

So, I have tried adding a reference qualifier for the second reference field variable for that catalog item.

..........^sys_id!=javascript:current.variables.var_second_variable^EQ

 

the reference qualifier ends like this.

 

I have tried this in simple and advanced.


In simple
I have added a AND condition and choose
Sys_id    is not     javascript:current.variables.var_second_variable


However, this is not working. 

How else should I have written this reference qualifier to exclude the user available in the first reference field?

 

Note: the second reference field have more reference qualifiers to exclude certain location users

1 ACCEPTED SOLUTION

Hi @Kvb Kiran ,

 

javascript:'active=true^nameISNOTEMPTY^u_user_type!=Customer^ORu_user_typeISEMPTY^location.countryLIKENetherlands^sys_id!='+current.variables.your_variable_name

 

note it's ":" not ":";

 

and replace your_variable_name with your actual variable backend name

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

8 REPLIES 8

@Kvb Kiran 

try forming the encoded query on sys_user and then copy that and use in your advanced ref qualifier.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you
Solution provided by Chaitanya worked well.

 

However, I will also try this way. 

Did you mean, navigating to the sys_user table and user filter, then copy the query?

Never mind. It worked.
Thanks a lot for your quick responses.

 

I have missed to remove the '^EQ' at the end.
After removing, the complete script started to work.

try below:

 

javascript:'sys_id!='+current.variables.your_variable_name+'^active=true^nameISNOTEMPTY^u_user_type!=Customer^ORu_user_typeISEMPTY^location.countryLIKENetherlands'


Raghav
MVP 2023