UI Builder hiding components based on logged-in user's GROUP

CodeHearted
Tera Contributor

In ServiceNow UI builder configurable workspace, what is the best way to hide a component based on the current logged-in user's group? I know how to hide a component based on the current user's role utilizing the api user.roles but I want to use the current user's group as the criteria instead. I really appreciate the help.

1 ACCEPTED SOLUTION

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

 

You have more than one option to choose from.

1. You can use look up records data source to get the groups of current logged in user. Then you can use the output to determine if you need to hide/show the component.

JagjeetSingh3_0-1673185495119.png

 

Below are the conditions you can use in your data source.

JagjeetSingh3_1-1673185579845.png

 

2. You can create your own transform data source to execute your logic and then the output can used to determine if you want to show the component or hide it. See here my article series to know how you can create your own transform data source.

 

 

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

View solution in original post

3 REPLIES 3

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

 

You have more than one option to choose from.

1. You can use look up records data source to get the groups of current logged in user. Then you can use the output to determine if you need to hide/show the component.

JagjeetSingh3_0-1673185495119.png

 

Below are the conditions you can use in your data source.

JagjeetSingh3_1-1673185579845.png

 

2. You can create your own transform data source to execute your logic and then the output can used to determine if you want to show the component or hide it. See here my article series to know how you can create your own transform data source.

 

 

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

@JagjeetSingh  how can we use it in the container visibility script. The first option from above. can you please help on that

CodeHearted
Tera Contributor

Thank you so much!!