Skip to main content

Filter LookUp records based on current user signed in and specific security role

editSubscribe (0) ShareShare
Posted on by 863


I would like to filter the lookup field to populate only the records that are related to the current manager signed in and based on a specific role assigned to him.
For example, Manager A has the security role A and the below team:
User A, User B, User C

Manager B has the security role A and the following team: User D, User E

When the form is loaded, and manager A is the user signed in, the only records that should be filtered in the lookup are User A, B, and C and he can't access User D or User E because those users do not belong to him.

In addition, if the current user has the system admin role he should be able to see and search for all the records.

Below is a screenshot that shows the manager field (LookUp on the user's table) assigned for each resource:

What's the best way to achieve the above requirement? Can please someone provide a sample code?

Any help is highly appreciated.

Best regards,