+ Start a Discussion
Jason MacFadyenJason MacFadyen 

Formula field string on Account listing all Contact names of specific Record Type

I am new to Salesforce and our users are having difficulty identifying what contacts are in which accounts. Our Accounts will generally contain no more than 2 Contacts with "Student" RecordType.  My thought was to create a formula field on Account that is a string of all Contact names for that Account and add that to search layouts but I cannot find a way to do this.  Is this possible?  Ideas on a better way to handle it?
DavidGantDavidGant
Jason,

Since Contacts are children of an Account and there could be many Contacts under one Account, Account-level formula fields cannot pull in Contact data. You would need to use some more advanced functionality to accomplish your goal.

Here are a couple fo options:
  1. Code - On the Account object create a custom text field and then use Apex (Contact Trigger and Trigger Handler Class) to recalculate the value for the text field whenever there is a change to a Contact
  2. Non-code - Create the same Account field, but use Visual Workflow (just called Flows in the Setup area) that will recalcuate the field value instead of writing code. You will need to use Process Builder to call the Flow when a Contact is edited.
Both of these solutions should get you the desired result but neither is a beginner level task.
Jason MacFadyenJason MacFadyen
Thank you David.  What I do not know is what the code would be to populate he field.  How can I create a string of Contacts related to an Account?  Does it have to be an array?  I did that before in VB but stumbled my way through it.  Is there an easy way to concatenate the names of all Contacts related to an Account into one string?  Thanks.