function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jose María Nicolás ArfelisJose María Nicolás Arfelis 

How to convert a Related List to a Comma Separated List

Hi all,

I am looking for possibilities to catch values in a specific Master-Detail field within a junction object.
For example, I have the object Event. There is another object Account --> Record Type "Professors". Event and Professor have a many to many relationship.
For the many to many relationship I created a junction object Relationship Professor - Event. This junction object hast two Master-Detail fields. One pointing to Event and one pointing to a Professor.

Now our client would like to have the values on the Professor Master-Detail fields as comma separated values in a field on the Event object, so they can have a tabular view when entering to the Events tab seeing the Professors participating on that event. For this I created the field "Professor (s)" on the object Event.

For example, if we have:

EVENT         PROFESSOR
Event X        Michael Fox
Event Y        Tanya Mitchells

The field Professors should show: Michael Fox, Tanya Mitchells.

After looking for possible solutions how to implement this, I found this link:

http://blog.jeffdouglas.com/2012/04/10/convert-a-related-list-to-a-comma-separated-list/

when I implemented it, it didn't work totally.
When you delete a professor in the list of professors (Account --> Record Type "Professor"). The related record in the junction object gets deleted. But the field Professor(s) on the object Event doesn't update automatically with the trigger mentioned in the link above. You have first to go to one of the records in the junction object Relationship Professor - Event --> press button Modify on that record and then save. Only after doing this, the field "Professor(s)" on Event gets updated.

Have someone dealt with such a requirement?. Is there something missing in the proposed code in the link mentioned above?.

 
NagendraNagendra (Salesforce Developers) 
Hi Jose,

There you go,here's one of the most excellent blog from Jeff Douglas answering your question.For complete information please check here http://blog.jeffdouglas.com/2012/04/10/convert-a-related-list-to-a-comma-separated-list/

Kindly mark this as solved if it helps.

Best Regards,
Nagendra.P
Andrew MoomeyAndrew Moomey
Is there a more updated way to do this without custom trigger and handler? I am not a developer but have a business need for this. If there is not an updated way, can someone please tell me where the trigger should be built and where the handler is made?