Summer ’19 introduces Enhanced Related Lists
Check out this great video to see Enhanced Related Lists in action.
Enhanced Related Lists may be all you need before implementing the solution outlined in this blog post. If not, continue reading =)
In this post I will show you how to use native related lists to separate and filter records with NO code and NO visualforce.
Have your users ever asked for a way to filter related lists or have multiple related lists that separate records based on criteria – much like how Open Activities and Activity History related lists separate Task records based on their status?
A common request I get is how to filter the Contacts related list on Account page, for example, to separate out “Active vs. Inactive” contacts. Or filter out HubSpot noisy activities from the real meetings and logged calls entered by the sales team. Or for customers who track forecasting opportunities along with actual orders in same Opportunity object but with different record types, how to show them in different related lists.
Sounds reasonable, right? Unfortunately, as of this writing, Salesforce currently does not natively support filtering related lists. There are two big ideas on the Idea Exchange requesting this very feature and are tentatively on the road map (safe harbor):
Workarounds exist but usually involve writing code or using a third-party app. One free workaround is Custom Related Lists by Kevin Poorman (@Codefriar). However, even then these solutions aren’t truly related lists as we know them but rather a fancy visualforce page you add to the page layout in a section among the other fields on the page layout. If you’re ok with using a solution that isn’t a native related list then that may be the way to go for you.
In the Visualforce approach, you’re limited to placing it among a field section on the page layout and can’t position it with the native related lists. So that’s a double whammy – had to write code and it doesn’t match the standard UI of related lists.

Creating multiple related lists each using different filtering logic without any code or visualforce
Going back to our original example of trying to separate “Active vs. Inactive” Contacts, I’m going to show you how to setup multiple Contact related lists you can add to the Account page layout and each related list will filter the account’s contacts differently. This solution involves custom lookup fields and process builder.
Lookup Fields
This #NoCode solution for multiple related lists exploits the fact that every time you add a new lookup field on an object then the object the field references gets another related list showing those child records.
In our Contact example, let’s assume we have a custom checkbox called “Active” and that we want show on the Account page contacts separated out into two native related lists: one for Active contacts and one for Inactive contacts.
Using the lookup field trick, add two new lookup fields on the Contact object that both reference the Account object. You can name these whatever you want, perhaps “Active Lookup” and “Inactive Lookup”. You won’t ever show these fields on the Contact page layout, they are just behind-the-scenes fields to make the magic happen.
Process Builder
Next we will automate using Process Builder the setting and clearing of these two new lookup fields. Whenever one of these lookup field’s value is set then on the Account page layout those contacts will appear in the related list associated with that lookup field. When the field is cleared then the contact record no longer will appear in that related list. And like magic we can now let our users intuitively toggle the “Active” checkbox on the contact page and the system will appropriately separate the contacts between the two related lists on the account page!
Our process will have two decision nodes, one checking if the contact “Active” checkbox is checked (true) and the other if it’s unchecked (false). When the checkbox is checked then we will have an immediate action update the contact record to do two things:
- Set the “Active Lookup” field with the value of the contact’s account ID
- Clear the “Inactive Lookup” field by setting it to value $GlobalConstant.null
As you can imagine, the same two actions occur for the other decision element but vice versa, we’ll set the “Inactive Lookup” and clear the “Active Lookup” fields.
Activate the process then update some contacts to be active or inactive. Add the new related lists to your account page layout and voila! If you wanted, you could remove the standard “Contacts” related list and just keep the “Active” and “Inactive” related lists (to me that feels more like the “Open Activities” and “Activity History” experience of Task records that I was going for).
Custom Buttons
The last step is to now create custom buttons for “New Contact” and “Merge Contacts” for your custom related lists. Check out slide 39 of my presentation for screen shots and instructions. The reason we need to do this is because one, the “New Contact” button on the custom related lists binds the account id name/value to the lookup field associated with that related list (either “Active Lookup” or “Inactive Lookup”) instead of the standard “Account Name” field, and two, because the “Merge Contacts” button isn’t automatically added to the custom related lists. Once you create those custom buttons and add them to the related lists on the page layout you’re golden!
Hi Doug,
How would this work with Contacts related to Multiple Accounts?
Thanks!
Kris
LikeLiked by 1 person
Hi Kris,
Could you clarify what you mean? What is your concern?
This trick is based on Lookup fields that exist directly on the object, the Contact in this scenario.
The feature “Contacts related to Multiple Accounts” is a junction object allowing a contact to be linked to multiple accounts, but those associations are not Lookup fields on the Contact object itself.
LikeLike
Hi Doug! Then that answers my question. I will not be able to use this feature for that purpose. Damn. We have a lot of Contacts that are no longer active tied to accounts. I was hoping to provide an easy way to filter out those inactive type records on the related list. We will have to do that via a vf component then or by some other means.
Thank you for the quick reply!
Kris
LikeLiked by 1 person
Hi, I am trying this for open cases related to an account and I have created the two lookup fields and the process builder however I cant see the related list anywhere, also I am in lightning is that an issue? Thank You
LikeLike
The only quirk I see is that it doesn’t do this live for all the pre-existing contacts that are already checked as active or inactive. The process fires when a contact record is edited or created. I need to populate the filtered list with thousands of existing contacts that already are inactive or active….
LikeLiked by 1 person
Hi Raegan, correct. The related lists show data based on what is populated in the Lookup fields. Pre-existing data won’t have any values in the newly created Lookup fields. You can use Data Loader to Export the records then perform an update on them to cause process builder to fire.
If you don’t want to export the data, then you might try my other app Mass Action Scheduler.
LikeLike
HEY DOUG! I just implemented this in my UAT environment because I had a use case where they wanted tasks created from mass emails in a separate related list from the tasks they create themselves. (I think you actually mention this type of use case in the blog). The problem is that our accounts are public and activities are controlled by the parent. When I clear the value of the standard lookup, and populate the custom lookup with the process, the sharing settings are ignored – it doesn’t recognize the account populated into the custom account lookup as the ‘parent’. This means in my custom lookup related list, folks can only see tasks that are assigned to them. There are no sharing rules for activities so I can’t open up visibility that way. Do you have any ideas for a workaround?
LikeLiked by 1 person
Hi Krista,
Glad you’re finding use out of this solution!
Unfortunately, Tasks are a unique object unlike what you’re accustomed to with custom objects and most other standard objects.
To maintain the sharing, I think you’re going to be forced to leave the standard Task.WhatId field alone, but only toggle between the custom lookup field being populated or not. In essence, keeping the normal activities history related list as-is but with the capability of introducing one new filtered related list for accounts.
LikeLike
It really is a great solution, but you’re right – and that’s how I originally built it out. Back to Plan A! Thanks for your help, Doug!
LikeLiked by 1 person
Hey Doug,
I am hitting a snag on my configuration. Every time I toggle the “Active” true or false checkbox, I get a saving error under the look field stating “Value does not exist or does not match filter criteria”
Any ideas?
LikeLiked by 1 person
Hi Joseph, can you share screen shots of your config? My guess is either the lookup field you’re updating has lookup filters defined on it and the value your process builder is trying to set the field to doesn’t meet criteria, or process builder may be trying to bind an incorrect value into the lookup field (e.g. a value or ID that doesn’t match the object type of the lookup field).
LikeLike
Hi Doug,
I’m having a bit of trouble when it comes to the new contact button. When using your value it still does not fill in the account and it also does not prompt for record type selection. Any help would be great.
LikeLiked by 1 person
Hi Nick, can you provide a screen shot of your config so far?
LikeLike
Hi Doug,
Below is the screen shot.
https://drive.google.com/file/d/1xZMbMEj6bih6YilhN9XfaMqb0b-D7Lyy/view?usp=sharing
Thanks,
Nick
LikeLiked by 1 person
Thanks. I think this URL trick to pre-define form field values only works in Classic. Without writing code, I’m not sure how to make that work for Lightning Experience. Sorry!
LikeLike
Hi Doug,
Since the 23rd June I haven’t “heard” of any answer to my question. I don’t see any other solution than setting the duplicate rule to Allow and Report (not Alert). I wish I could know how Keri-Ann solved this so far. Mary.
LikeLike
Hi Mary, thanks for the feedback. I’m running behind on following up on blog comments and email. Hopefully will have some time to dig in to this soon to get you an answer. Thanks for your patience!
LikeLike
Hi Doug,
I’ve implemented this to show a filtered list of Contacts that have a certain attribute on the Account object. I’m not using the custom button portion, as I only needed the New Contact button. It works beautifully in Classic, but for some reason in Lightning the filtered related list doesn’t load properly and just keeps showing the spinning circle on any Account where it would be populated with records. On accounts where the list has no relevant records it looks normal. Are you aware of any reason this might be the case?
Thanks,
Rhys
LikeLiked by 1 person
Hi Rhys, I’m not aware of why the related lists would not be loading in Lightning Experience. I recommend that you open a case with Support so they can investigate. Thanks
LikeLike
Hi Doug,
I want to implement this for a similar scenario.
My custom object is called “Policy”
There are parent policies and child policies. the Field that determines that is called “Monoline/Package” if the selection is “Package LOB” then it is a child, anything else its a Parent.
On the account page I would like to limit the related list to only display parent policies and ignore any child, Can you advise my steps starting from the Process Builder?
Thank you!
LikeLiked by 1 person
Hi Mendel,
Similar to the scenario in this blog post, your Process Builder on the Policy object would have decision criteria that when it is a “parent policy” you would copy its’s account lookup field value into one of the custom account lookup fields used for creating the filtered related list. Whenever a Policy record is not a “parent policy” then you would use Process Builder to set to null the value in the custom account lookup field used for driving the filtered related list.
LikeLike
Hi Doug,
Thank you for writing this blog. I have this somewhat working with a few issues. 1. Let’s say I have an account with an open case and a closed case. On the account, I can see both the Account Open Case and Account Closed Case. On the case layout, I’m only able see Open cases if the case is open and closed cases if the case is closed. 2. In order for the related cases to show it’s forcing me to add the lookups to the case details section. 3. I have those lookup fields set to read only in both Field Accessibility and the layout and they’re still editable is there another place to set them as read only?
LikeLiked by 1 person
Hi Laura,
I’m not completing understanding your scenario. Could you share some pictures of your configuration?
Are you saying that unless you have the custom account lookup fields on the Case page layout then the “Open Case” and “Closed Case” filtered related lists don’t appear on the Account page layout?
Case comes with a standard Account lookup field, that’s the only one that should be on the Case page layout for users to edit.
To create custom filtered related lists, you’ll add two new account lookup fields on the Case object, but not to the page layout. Only Process Builder needs to work with these two new lookup fields. When the case is “open” then PB will copy the Case.AccountId value into your Case.Open_Account__c custom field and set the Case.Closed_Account__c field to null. And when the case is “closed” then do the opposite.
Hope that helps,
Doug
LikeLike
Hi Doug,
Thank you very much for helping Active/ Inactive contacts related list on Accounts. Managed it to work with your step by step instruction.
Now, I’m trying to create related list to filter out the Pardot created tasks from the Activities History on Account/ Contact. All the Pardot related activities have; Task Type= Email and Created by=Pardot Connector user.
I’ve created an Activity Custom Field to have non-pardot activities in. In process builder, I added condition on Task Object, 1. Task.CreatedBy.ID Does not equal Pardot connector user’s ID, 2. Task.Task_Type doesn’t not equal (String) Email,Downloaded
It’s still showing the pardot activities, like the default Activities History.
What conditions can filter out the pardot activities from the new related list? Please help.
Thank you very much for your time and effort.
Jami
LikeLiked by 1 person
Hi Jami,
I’m glad you liked this solution. Thanks for your kind feedback 🙂
After you create the custom field and process automation, you’ll need to update all the existing records so that the custom field gets populated. That should then filter the records into the custom related list.
If records you don’t want are showing in the custom related list, review the criteria in process builder and/or other processes/workflows/triggers in the org that may be modifying the field value.
When a record no longer meets the criteria for what you want to be in the custom related list, your process needs an action to assign that custom lookup field’s value to null so the record will not show in the list.
Hope that helps!
LikeLike
I have an issue where I only want to show active campaigns on the “Campaign History” . Is that possible with declarative approach ?
LikeLiked by 1 person
Hi Ummair, using the technique in this blog post, you could create a custom related list that you name “Active Campaign History”. Your criteria in process builder would populate or clear the custom lookup field field based on if the campaign was active or not.
LikeLike
Dear Douglas,
We want to use the AccountContactRelation object to map the account / contact relationships from a third-party system in Salesforce. In this system, there is no “primary” account, all account contact relationships are equal. As a first option we could use a dummy account which is always set as a direct account in Salesforce. All other secondary relationships will be created and deleted via SOAP API calls. The primary dummy account unfortunately appears in the “related accounts”-lists on the Contact record, which makes little sense and adversely affects UX.
I came along this post and I am wondering, whether it is possible to use your approach to filter out the dummy account from the “related Accounts” list view. I could set a checkbox on the relationship record “Dummy__c” and try to filter based on Process Builder but actually I do not know how to achieve that.
Do you have a hint fpr me?
Regards,
David
LikeLike
Hello Doug,
What a great post!
I created a new Approvals Related List on the Quote object that only shows the most recently submitted Approvals, as opposed to all Approvals (recalled etc.) We have Advanced Approvals with archiving ON for reporting purposes and the related list was a complete mess.
Amazing!
W
LikeLiked by 1 person
Thanks for the kind feedback, Weronika, glad you liked this solution!
LikeLike
This is great. Thanks!
LikeLike
Hi Doug,
I have create process for opportunity stage but it is not working for me can you suggest
LikeLike
Worked perfectly, thank you.
As noted in one of the comments – using DataLoader to export just the id to a CSV and then import and fire the process builder will put existing records into the relevant lists.
LikeLike
That should read update, rather than import…
LikeLike
Hi Doug,
I have implemented but it is working for only new records for old records it will not working
LikeLike
Hi Doug,
This is really great and I love the detail! I have been spinning my wheels all day on this and hoping you can help me! My scenario is that I have a request to filter opportunities that are created from an ‘original opportunity’ by their record types. I have done multiple process builders and just can’t seem to get it right. There are (2) record types: 1 called Change Order and the other one called Internal Technologies. Is there a way I can post what my current pb looks like to see if you can see what it is that I’m not doing correctly?
Thanks Doug! I’m in tears right now :((
LikeLike
This has been really helpful and I’ve used it to create a separate related list for Lost opportunities, unfortunately, I can’t seem to update past records. I’ve tried doing the export and update but it doesn’t do anything. I have tested by editing a single opportunity and then saving, also nothing. It only works on past opportunities if I put the parent account name in the new field. Any help would be muchly appreciated.
LikeLike
Hi Doug,
This non-code trick is awesome and it is working great for our organisation – thank you.
We have one request…how to show the “Related Contacts” list filtered to just show the active contacts as the Related Contacts list still shows ALL contacts. Then the custom Active contacts list can be hidden so we all we are left with is the Related Contacts list showing just active contacts and the custom Inactive Contacts list.
We require the Related Contacts because we allow Contacts to be associated to multiple Accounts.
Really hoping this can be achieved.
Thank You.
LikeLike
Thank you SOO much. Wonderful walkthrough and did exactly what I wanted. I used your method tie Organization to Products. Some products are approved (active) and some are clinical trials (inactive).
LikeLike
I used this to create a related list for “Open Opportunities”. Works like a charm. Thank you!
LikeLike
To make the New Contact button work in Lightning, add below URL :-
/lightning/o/Contact/new?useRecordTypeCheck=1&defaultFieldValues=AccountId={!Account.Id}
You can remove “useRecordTypeCheck=1” to skip record type selection screen. Also we dont need any retURL here.
LikeLiked by 1 person
Hi Doug,
Can we add or remove columns from this ‘active contact’ list view?
Thanks in advance.
LikeLike
This is ingenious, but now in 2021 you can create a list view (with filters) for the object you want as a related list, and then add this list view it as a component using the lightning page editor.
LikeLike
Oh wait, nevermind, you can’t filter per the parent on the list view.
LikeLike
Please Help! This is awesome but I cannot figure out the NEW button. I use lightning btw. Everything set up perfect and process is awesome EXCEPT my Related Object is called Carpet_c This is where the list view NEW button should be on the Account page layout but whatever I am trying to put for a url is obviously giving me a something went wrong error. I cannot get anything to work by pasting urs as it is a contact and Im not sure what to change. This is the last part of a HUGE search for a solution LOL. Thanks so much!
LikeLike
Hi Doug, I believe your example refers to adding a new custom Contact ‘Active’ field. Would it be possible to use this process to filter Active vs Inactive Contacts via the out of the box ‘Account Contact Relationship – IsActive’ field? Meaning if the Account Contact Relationship is set as ‘Active’ (checked) it would appear in a separate related list?
Thank you
LikeLike