Create Advanced ACL

sparkles
Tera Contributor

Hello,

 

I need is to create ACL where user can see only tickets assigned to the group he is member of. I have 3 groups (Eastdpt),  (Westdpt) and (National). Currently all groups have access to each other's tickets. I need ACL that allow (National) to see both Region’s tickets, (westdpt) to see the West Region’s tickets and (eastdpt) to see the East Region’s ticket. It’s a custom table and has one role. The sys user role is x_acc_region_.acc_user

 

Eastdpt and Westdpt are assignment group but National is a security group

2 ACCEPTED SOLUTIONS

SwarnadeepNandy
Mega Sage

Hello @sparkles,

Here is an example of how such an ACL might look like:

  • Name: x_acc_region_table.read
  • Type: Record
  • Operation: Read
  • Table: x_acc_region_table
  • Script:

 

// Get the current user's groups
var userGroups = gs.getUser().getMyGroups();
// Create a GlideRecord object for the x_acc_region_table
var gr = new GlideRecord('x_acc_region_table');
// Add a query to filter records by assignment group
gr.addQuery('assignment_group', 'IN', userGroups);
// Execute the query
gr.query();
// Check if any records match the query
if (gr.hasNext()) {
  // Return true to allow access
  return true;
}
// Return false to deny access
return false;​

 

Hope this helps.

 

Kind Regards,

Swarnadeep Nandy

View solution in original post

Aman Kumar S
Kilo Patron

Hi @sparkles 

You should try Query BR for this use case and not the ACL, it will not be good for user experience as you will find empty rows in the list layout.

Best approach would be combo or Query BR and ACL.

 

Best Regards
Aman Kumar

View solution in original post

2 REPLIES 2

SwarnadeepNandy
Mega Sage

Hello @sparkles,

Here is an example of how such an ACL might look like:

  • Name: x_acc_region_table.read
  • Type: Record
  • Operation: Read
  • Table: x_acc_region_table
  • Script:

 

// Get the current user's groups
var userGroups = gs.getUser().getMyGroups();
// Create a GlideRecord object for the x_acc_region_table
var gr = new GlideRecord('x_acc_region_table');
// Add a query to filter records by assignment group
gr.addQuery('assignment_group', 'IN', userGroups);
// Execute the query
gr.query();
// Check if any records match the query
if (gr.hasNext()) {
  // Return true to allow access
  return true;
}
// Return false to deny access
return false;​

 

Hope this helps.

 

Kind Regards,

Swarnadeep Nandy

Aman Kumar S
Kilo Patron

Hi @sparkles 

You should try Query BR for this use case and not the ACL, it will not be good for user experience as you will find empty rows in the list layout.

Best approach would be combo or Query BR and ACL.

 

Best Regards
Aman Kumar