The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Only display records created by the currently logged in user if NOT an admin.

david-mendoza
Tera Contributor

Hi! I have a custom table that contains records for repair requests. Using a business rule, I had made A Before Query rule that only displays records made by the currently logged in user with this script:

 

 

(function executeRule(current, previous /*null when async*/ ) {
    current.addQuery('sys_created_by', gs.getUser().getName());
})(current, previous);

 


This achieves my goal of hiding records from other users, but wouldn't this make it such that admins accessing the table list will also be only be able to see records created by them? Is there a more elegant solution? Perhaps an ACL? If so, how should I go about it? Any guidance on the matter would be appreciated.

Edit: My solution instead was to doing an ACL instead and putting a filter on the List of Records Link Type application module like Maik suggested

 

ACL

 

davidmendoza_3-1715244352270.png

 

 

davidmendoza_0-1715244241623.png

 

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Your question "Is there a more elegant solution?" cannot be answered as you did not explain the reason for your approach. What is the underlying requirement?
To solve your concern regarding admin access, you could add the following:

(function executeRule(current, previous /*null when async*/ ) {
    if (!gs.hasRole('admin')) {
      current.addQuery('sys_created_by', gs.getUser().getName());
    }
})(current, previous);

 

View solution in original post

5 REPLIES 5

hey what if it affecting approvals in portal