how to hide workspace for specific groups or role

Su Tyagi
Tera Contributor

Hi all,

I want to hide asset workspace from specific groups. I tried using ACL for ux path but didn't get any success.

Any happy would be highly appreciated,

 

Thanks

Su

13 REPLIES 13

No, it didn't work. I don't want to use sys_id of the group. I want to restrict for role rather which given to mutliple groups. Not sure, why can't you see the script in the attached screenshot but here is what I am using.

answer = !gs.getUser().hasRole('heaplus_user');

@Su Tyagi 

You need only 1 ACL

Also use advanced script in that to check group membership

I already shared the script above

answer = !gs.getUser().isMemberOf('Group Name');

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

Ajay_Chavan
Kilo Sage
UX Route ACL (Primary Recommended Method)

The most effective method is to create UX Route ACLs. For each workspace you want to restrict, create two ACL records ServiceNow CommunityServiceNow Community:
Step-by-Step Process:

1. Navigate to Access Control Rules (ACLs)

Go to System Security > Access Control (ACL)

2. Create Two ACL Records for Each Workspace:
First ACL:

Type: ux_route
Operation: read

Name: now.<workspace_URL_path>.home
Roles: Add only the roles that should access the workspace How to grant the workspace access to the specific role users under workspaces 

Second ACL:

Type: ux_route
Operation: read
Name: now.<workspace_URL_path>.*

Roles: Add only the roles that should access the workspace Workspaces: How to hide/ restrict users Workspace based on roles

For Asset Workspace Example:
ACL 1: now.assetmgmt.home
ACL 2: now.assetmgmt.*

Important Note: If the workspace URL contains "/" replace it with "." in the ACL name Workspaces: How to hide/ restrict users Workspace based on roles


Script Example for Group-Based Restriction:
javascript// In ACL script section for group-based hiding
var userGroups = gs.getUser().getMyGroups();
var restrictedGroups = ['finance_group', 'hr_group']; // Add group names

for (var i = 0; i < restrictedGroups.length; i++) {
    if (gs.getUser().isMemberOf(restrictedGroups[i])) {
        return false; // Hide workspace from these groups
    }
}
return true; // Show to all other users
Glad I could help! If this solved your issue, please mark it as Helpful and Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****

Hi Chavan,

I am getting the syntax error with the cod eyou had provided above.