Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

How to Maintain visibility conditions for component in ui builder servicenow

harinya
Tera Contributor

Hi All,

I have created a component on a Landing Page/Dashboard in UI Builder. The dashboard itself is visible to users belonging to 6 different groups, but there is a requirement that component should be visible only to 3 groups.

While configuring the component, I can see the Hide Component option with values True, False, and None. I tried using a script-based visibility condition, but it is not working as expected.

harinya_0-1779697519497.pngharinya_1-1779697602388.png

 

Could anyone please guide me on the correct approach to control component visibility based on user group membership in UI Builder?

I am new to UI Builder, so any suggestions or examples would be greatly appreciated.

Thanks in advance!

4 REPLIES 4

Ankur Bawiskar
Tera Patron

@harinya 

did you try using gs.getUser().isMemberOf() in that script and see if logged in user belongs to any of those groups?

based on that return true/false

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

yashkamde
Mega Sage

Hello @harinya ,

 

Refer this for step to step guide :
Practical UIB Examples: Hide a container/component based on the user's role 

 

If my response helped mark as helpful and accept the solution.

Tanushree Maiti
Tera Patron

Hi @harinya 

 

refer this article:

UI Builder - Controlling the visibility of components

UI Builder - Component Visibility Logic

http://youtube.com/watch?v=mEhtN5SslZ8

 Builder Deep Dives: Conditional Renderer Component (New in Yokohama!)

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Tanushree Maiti
Tera Patron

Hi @harinya 

refer this article:

UI Builder - Controlling the visibility of components

UI Builder - Component Visibility Logic

http://youtube.com/watch?v=mEhtN5SslZ8

 Builder Deep Dives: Conditional Renderer Component (New in Yokohama!)

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti