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-28-2023 07:50 AM
Hi, you can do this in a business rule like the following defined on the incident table and 'caller_id' field:
change the table as desired. Advanced script:
restrictIncidents();
function restrictIncidents() {
var u = gs.getUserID();
current.addQuery("caller_id", u);
}
change the function name and field ('caller_id') as desired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2023 08:05 AM
Thank you. Great! It worked as expected!!
I want to ask additional question.
I want to list User_name filed is me and User_name filed is empty.
In other word, the list screen is showing User_name is me and empty records.
How I can do it ?
Regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2023 11:22 AM
Hi,
There happens to be an OOB Query BR on incident table that will limit the visibility of records. Did you give it a check?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2023 01:44 PM - edited 10-28-2023 01:46 PM
Look in sys_dictionary for your field name. There is no field named 'User_name' in my instance. There are 59 fields with column name = 'user_name', only 4 that are Reference fields to sys_user table.