How to add a role to a tab seen on a Workspace

Alex Wyckmans
Tera Contributor

Hi All,

 

Under the Toyo version, we noticed that the KPIs tab under the workspace "Platform Analytics Workspace" can also be called up by end users.

 

I would like to have assigned a role (pa_viewer) to this so that not everyone gets to see these figures. So it is not the intention to deactivate this function. However, I can't immediately find how to add this role. Any ideas?

 

AlexWyckmans_0-1687163987317.png

 

1 ACCEPTED SOLUTION

JagjeetSingh
Kilo Sage
Kilo Sage

Yes, below is how you can do it.

1. Open UI Builder and open the workspace.

2. Go to "Analytics Center"page.

3. You'd notice that the page is read only so you have to duplicate the variant. Do it in the same scope as of original page and the new variant would be editable.

4. Now, you must add the hide condition on your tab. To do this click on "Tab set 1" component > Click on the configuration icon on KPIs tab(You'll find this in the configuration panel on right hand side).

JagjeetSingh_0-1687261636838.png

 

5. Add the condition to hide the tab. Hover on it and click the script icon. Use below script to validate role.

 

/**
  * @Param {params} params
  * @Param {api} params.api
  * @Param {TransformApiHelpers} params.helpers
  */
function evaluateProperty({api, helpers}) {
  let userRoles= api.context.session.user.roles;
  return !userRoles.includes("pa_viewer");
}

 

6. Mark the OOTB variant inactive and that's it.

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

View solution in original post

1 REPLY 1

JagjeetSingh
Kilo Sage
Kilo Sage

Yes, below is how you can do it.

1. Open UI Builder and open the workspace.

2. Go to "Analytics Center"page.

3. You'd notice that the page is read only so you have to duplicate the variant. Do it in the same scope as of original page and the new variant would be editable.

4. Now, you must add the hide condition on your tab. To do this click on "Tab set 1" component > Click on the configuration icon on KPIs tab(You'll find this in the configuration panel on right hand side).

JagjeetSingh_0-1687261636838.png

 

5. Add the condition to hide the tab. Hover on it and click the script icon. Use below script to validate role.

 

/**
  * @Param {params} params
  * @Param {api} params.api
  * @Param {TransformApiHelpers} params.helpers
  */
function evaluateProperty({api, helpers}) {
  let userRoles= api.context.session.user.roles;
  return !userRoles.includes("pa_viewer");
}

 

6. Mark the OOTB variant inactive and that's it.

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023