Way to list only records that value of User_name filed is me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2023 07:26 AM
I have some records.
Those records has User_name filed.
User_name is Reference for sys_user.
I want to list only records that value of User_name filed is me.
As an example:
When UserA logged in, it shows only value of User_name filed is UserA
When UserB logged in, it shows only value of User_name filed is UserB
I tried to find expected filter, it can't select logged in user name like gs.getUserID().
I think that I can do it using business rule of addEncodedQuery, but I don't have any idea...
How I create a business rule to resolve this issue.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 06:31 AM - edited 10-29-2023 12:00 PM
Try the following script to include records where the desired field is empty:
restrictRecords();
function restrictRecords() {
current.addEncodedQuery('assigned_toISEMPTY^ORassigned_to=javascript:gs.getUserID()');
}
replace 'assigned_to' with your field. And maybe add a Condition: !gs.hasRole('admin') so users with the admin role can see all records.