I've a custom lightning page for a custom object where I'd like to show all the related contacts from an account that have a specific role. Example: Object Custom, Account name set -> List all the contacts having the role set as Sales Representative, even those not being set as main/direct to the account but having the role set for the selected account. Account > Coca Cola Contact John Doe (Main account Food Gro Distributor, Related account Coca Cola => Role Sales Rep.)

How can I do this? I've managed to show the contact related to the account but I can't find a way to filter by the role.

Any thoughts, ideas, best practices, on how to achieve this? Regards enter image description here

  • I'd suggest looking into the object AccountContactRelation. Feb 25 '20 at 13:05
  • @DrewKennedy, Can you please provide more details? The related list is linked to an account lookup. There is nothing to connect to the object AccountContactRelation
    – poypoy
    Feb 25 '20 at 13:33

You can do this via another lookup field and a process builder. You can create a lookup field on contact selecting account as parent. Also, a process builder to update the contact when contact role is Sales Representative while creation or update. The process builder should update the new account lookup field with its current account.

This way, you can add a new related list on account page where filtered contacts will come. See this:- Filter Related Lists without Code

  • thanks for your suggestion. In my business case, I've contacts related to multiple accounts and they aren't necessary set with contact role on the "main" account. Any thoughts on how we could tackle this?
    – poypoy
    Feb 25 '20 at 12:43
  • To get a proper answer, You must add all the relevant information into your question.Can you please update your question with this information? Feb 25 '20 at 12:48
  • Done but not sure it would be more clear. In other words, I just need to see only the contacts having a role set for the selected account, taking into account that a contact may have multiple related accounts & roles. So it should really stick to the selected account.
    – poypoy
    Feb 25 '20 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.