How can i restrict some user to view record in custom table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 01:43 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 02:44 AM - edited 09-15-2024 02:52 AM
Here's how you can set it up:
Steps:
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 03:48 AM
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;