Filter by Current User in Salesforce

Many admins would like to create reports and list views that filter automatically for the current user or a manager’s direct reports.  Without knowing another method, I have seen users create one report per user, per manager, etc. to satisfy this business requirement.

This seems like it really should be a standard feature in Salesforce, but so far the ability to filter reports based on running user is still an idea under product team review. (Vote Here! https://success.salesforce.com/ideaview?id=08730000000BpLkAAK)

The good news is a fix is pretty simple using formula fields.


The basic setup is to create a formula checkbox field that evaluates to true when the current user ($User.ID) matches a user lookup field on a record.

UserLookupField = $User.ID

This can be applied in a few ways.

Returns true for records belonging to the current user:

Owner.ID = $User.ID

Returns true for records belonging to the direct reports of the current user:

Owner.ManagerID = $User.ID

Returns true when a custom lookup field equals the current user:
Ex: An account has a Channel Manager along with Account Owner, Channel Manager wants to see all opportunities for accounts where they are the channel manager

Account.ChannelManager__c = $User.ID

Returns true when a value on user lookup field matches that of the current user:
Ex: You want to create a report that returns all opportunities under one department, not necessarily just direct reports.

Owner.Department = $User.Department

We could even show all results for the Channel Manager’s department:

Account.ChannelManager__r.Department = $User.Department

With these approaches, you should be able to create all the fields, on any object, that you need to filter list views and reports to the current user.


Example: ‘Opportunities belonging to Direct Reports’ List View & Report

Create a field on the Opportunity object using this formula: Owner.ManagerID = $User.ID

In the example below, I called mine ‘User Manager Check’

 

Create a list view that filters for this field being true and no matter which user clicks the list view, they will only see the results belonging to their direct reports (if any).

Do the same when creating a report, adding a filter for User Manager Check = True.  When a user runs the report, they will only see the results belonging to their direct reports (if any) – no need to create one report per user/manager/team ever again!

 

Leave a Reply

Your email address will not be published. Required fields are marked *