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

Ankur Bawiskar
Tera Patron
Tera Patron

@preethigovi 

you can show/remove it completely but not as per role

check this link and see if it helps

Hide a component on workspace based on role 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

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;

}

 

 

 

@Shruti  

Since we create a duplicate variant, how will we add that again on the page (record)?

It would be nice if you share the further details.

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

@Ankur Bawiskar  I guess we must keep lowest order to that duplicated variant to be added as default page record.