How to hide contextual side icon based on roles in HR workspace

preethigovi
Tera Contributor

Hi Team,

 

How to did template icon in HR workspace based on role. Like HR admin must only see it.

 

preethigovi_0-1754393676107.png

 

1 ACCEPTED SOLUTION

Shruti
Mega Sage
Mega Sage

Hi @preethigovi ,

To hide templates for all users

1. Navigate to sys_ux_page_property.LIST

2. Search "contextualSidebarVisibility"

Shruti_0-1754396516262.png

3. Remove table name from templates array to update the value 

Shruti_1-1754396548994.png

 

To hide templates for specific users based on role you need to create page variant in UI builder

1. Open UI builder -> HR agent workspace

2.  Duplicate Case SRP variant and update the variant order to 10

Shruti_2-1754396741438.png

Shruti_3-1754396795646.png

 

3.  Open the variant in editor and go to Tab sidebar -> Tab Templates

Shruti_4-1754397260880.png

4. Click on the settings and update the hide tab field

Shruti_5-1754397307782.png

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {TransformApiHelpers} params.helpers
 */
function evaluateProperty({
    api,
    helpers
}) {
    var roles = api.context.session.user.roles;
    if (roles.indexOf('admin') > -1 || roles.indexOf('sn_hr_core.admin') > -1)
        return false;
    else
        return true;

}

 

 

 

View solution in original post

6 REPLIES 6

@preethigovi 

can you share the detailed steps you followed so that it helps future members?

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

Lowest order number variant shows up by default. If a user is eligible for more than one variant they will get the one with the lowest Order as per the documentation -https://www.servicenow.com/docs/bundle/yokohama-application-development/page/administer/ui-builder/t...