How can i restrict some user to view record in custom table?

Ankit Kumar6
Tera Contributor

Hi Team,

How can I allow User A and User B to view all active and inactive records in a custom table, while ensuring that all other users can only view records where the u_owner field matches the logged-in user?

Note: The u_owner field in the custom table references the sys_user table.

 

Thanks in Advance

2 REPLIES 2

HIROSHI SATOH
Mega Sage

Here's how you can set it up:

Steps:

  1. Create a Read ACL for the custom table:

    • Navigate to System Security > Access Control (ACL) and create a new ACL rule for the custom table (table_name). Choose read as the operation.
  2. Set Condition for Specific Users (User A and User B):

    • In the Requires role field, you can add a custom role if you want to limit access to User A and User B using roles, or directly set a condition in the Advanced section.
    • In the Advanced script, specify that User A and User B can view all records by using a server-side script:

 

 

// Check if the current user is User A or User B
var userSysId = gs.getUserID();
if (userSysId == 'sys_id_of_UserA' || userSysId == 'sys_id_of_UserB') {
    answer = true;
} else {
    // For all other users, restrict access based on the u_owner field
    answer = (current.u_owner == gs.getUserID());
}

 

 

  • Save the ACL:

    • Once you set the conditions for User A and User B to view all records, and restrict other users based on the u_owner field, save the ACL.

This configuration ensures that:

  • User A and User B can view all records, regardless of the u_owner.
  • All other users can only view records where the u_owner matches their logged-in user ID.

 

※If you want to control the two users based on "role" or "user criteria", you can create ACLs without scripting.

Mani A
Tera Guru

read ACL on custom table

script:

if('userA_sysid'==gs.getUserID() && 'userB_sysid'==gs.getUserID() )

    return true;

else if(current.u_owner == gs.getUserID() )

    return true

else

   return false;