Agent Workspace Component Visibility/ UI Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 06:20 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 06:57 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 08:54 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 08:52 AM
Plan to have a different variant was canceled and it was decided to control the visibility of the component
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2023 05:49 AM
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.
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.
ServiceNow Community Rising Star 2022/2023