Agent Workspace Component Visibility/ UI Builder

Sanjana Jass
Giga Contributor

I have created a Component - Data Visualisation through UI Builder configuration for showing a report on the Workspace. I want to limit the visibility of this report only to a certain group. I know that when I open a component, there is a visibility icon that opens a script section. How can I use it to return certain groups only?

4 REPLIES 4

Michael Fry1
Kilo Patron

If someone without the roles opens the page, they just see a blank space or ?

I think you should have 2 variants - one with your data viz and the audience you need and another without the data viz.

Somehow even after defining the audience, the user was still getting redirected to the normal version of the agent variant. and later we dropped the drop of having a variant.

Sanjana Jass
Giga Contributor

Plan to have a different variant was canceled and it was decided to control the visibility of the component

JagjeetSingh
Kilo Sage
Kilo Sage

Although, I support the idea to control the visibility via variants only but if you must do it without variants then this is how you can do it.

 

1. Create a state parameter. Lets say it "hideReport". Set it to true by default.

2. Create a client script and check the logged in user roles inside it. You can get the logged in user roles via context.

const roles = api.context.session.user.roles;

//Add your logic to query the role and then set state parameter to true/false like below.

api.setState("hideReport", false); //This would make the report visible.

 3. Now, on your report component or the container component inside which the report is placed; bind the component visibility property to your state parameter.

JagjeetSingh_0-1684500513771.png

 

 

4. Now trigger your script from Page Ready event. Click on "Body" in content pane and go to events. There you can trigger your script to Page Ready event.

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023