To hide field choice in reference field

RakshithaM
Tera Contributor

I have a requirement with respect to Service Catalog. Could someone please assist me with this.

 

There are 2 fields - Location and User, where both are reference fields.

When we select Location as India in Location field, in User field particular user must be not visible. (Example: Abel Tuter must not be visible when we select Location as India)

 

Thankyou.

3 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@RakshithaM 

what's your business requirement here?

you can use advanced reference qualifier on User variable

Do you want to remove only 1 user when Location is India?

OR

this is for other locations also

If only for 1 then do this

javascript: var query = ''; if(current.variables.location.name == 'India') query='sys_id!=AbelUserSysId'; query;

 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

View solution in original post

Juhi Poddar
Kilo Patron

Hello @RakshithaM 

I believe that for location field you are referring to core_country table and for user field you are referring to sys_user table .

Now when configuring the reference field for user add the reference qualifier as follows:

javascript:current.variables.location=="8938b7111b121100763d91eebc0713ec" ? "active=true^sys_id!=5137153cc611227c000bbd1bd8cd2005" : "active=true";

8938b7111b121100763d91eebc0713ec : sys_id of location (India) 

5137153cc611227c000bbd1bd8cd2005: sys_id of user(Eg: Abel Tutor)

Adding screenshot for better understanding:

JuhiPoddar_0-1735301842813.png

Note: Please adjust the sys_id as per your requirement.

Hope this Helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

View solution in original post

@RakshithaM 

it should be combined as this

javascript: var query = ''; if(current.variables.location.name == 'India') query='sys_id!=27d3f35cc0a8000b001df42d019a418f'; query = query + '^nameINBlackberry,Bond trading'; query;

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

View solution in original post

13 REPLIES 13

Hi @Ankur Bawiskar,

Thankyou, accepted as solution and code is working.

Hi @Ankur Bawiskar ,

 

i tried implementing this same procedure for different table(Ex: Service table), it working as per required, but i wanted to add additional condition to this where this 2 will be different condition.

 

Condition 1: 

javascript: var query = ''; if(current.variables.location.name == 'India') query='sys_id!=27d3f35cc0a8000b001df42d019a418f';query;

 

Condition 2:

name=Blackberry^ORname=Bond trading^EQ

 

I tried combining this 2 conditions, one after another with + operator , but it was not working. Could you please help me with this.

 

 

@RakshithaM 

it should be combined as this

javascript: var query = ''; if(current.variables.location.name == 'India') query='sys_id!=27d3f35cc0a8000b001df42d019a418f'; query = query + '^nameINBlackberry,Bond trading'; query;

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

It's working. Thankyou very much @Ankur Bawiskar 

Juhi Poddar
Kilo Patron

Hello @RakshithaM 

I believe that for location field you are referring to core_country table and for user field you are referring to sys_user table .

Now when configuring the reference field for user add the reference qualifier as follows:

javascript:current.variables.location=="8938b7111b121100763d91eebc0713ec" ? "active=true^sys_id!=5137153cc611227c000bbd1bd8cd2005" : "active=true";

8938b7111b121100763d91eebc0713ec : sys_id of location (India) 

5137153cc611227c000bbd1bd8cd2005: sys_id of user(Eg: Abel Tutor)

Adding screenshot for better understanding:

JuhiPoddar_0-1735301842813.png

Note: Please adjust the sys_id as per your requirement.

Hope this Helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar