User table

srihyma
Tera Contributor

If the logged in user has an 'itil' role, filter the department lookup search to show only one value 'IT' in the user form
What is the best method?

4 REPLIES 4

Juhi Poddar
Kilo Patron

Hello @srihyma 

You can add the reference qualifier to the field.

Script:

javascript:gs.hasRole('itil') ? "name=IT":""

 Screenshot:

JuhiPoddar_0-1735964601489.png

Result:

JuhiPoddar_1-1735964669288.png

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

Ankur Bawiskar
Tera Patron
Tera Patron

@srihyma 

you can use advanced ref qualifier on the department field/variable

javascript: var query = ''; if(gs.hasRole('itil')) query = 'name=IT'; 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

@srihyma 

Hope you are doing good.

Did my reply answer your question?

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

Runjay Patel
Giga Sage

Hi @srihyma ,

 

You can add reference qualifier of department filed.

javascript:current.hasRole('itil') ? 'name=IT' : '';

RunjayPatel_0-1735977247444.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------