How to Create a Dynamic List View

newsletter Mar 24, 2024

Quick tip today!

If you ever need to dynamically filter a list view based on who is looking at it, you can use a formula field.

Imagine an account has a field called Lead Advisor which looks up to user records:

By default, Salesforce gives us a "My Accounts" list view to see all of your accounts.

But what do we do if we want to make a list view so that a user can see all of the accounts where they are the lead advisor?

One approach is to make one list view for each user, using a filter like "Lead Advisor = Nick Frates".... but that's tedious (and hard to maintain).

Enter the formula field!

Instead, we can create a formula like this:

It's a formula on the Account object that returns a number.

It will output 1 if the current user is the lead advisor, otherwise it will output 0.

IF( $User.Id = Lead_Advisor__c, 1, 0)

Now, we can create one list view with a filter that this field must equal 1.

And just like that, no matter who is looking at the list view, they will see only the Accounts where they are the Lead Advisor.

This solution works on any object in Salesforce (where you can make custom fields), and it works well in both List Views and Reports.

Hope it helps!

Salesforce Made Simple

Join the Salesforce Saturday newsletter. Every Saturday, you'll get 1 actionable tip on Salesforce technology or career growth related to the Salesforce Industry.

We hate SPAM. We will never sell your information, for any reason.