Skip to main content
Hi,

I've been researching and trying to make this code work so that I can concatenate the names of our sub-speakers at presentations for our conferences.  It's all within the same object (Speaker__c) with two different record types (Primary Speaker & Secondary Speaker).  When we change the record type to secondary speaker, we'll tie the primary speaker using (Main_Speaker__c) and would like to concatenate the full names (Speaker_Full_Name__c for both primary and secondary) into our Multiple Speakers text area (Multiple_Speakers__c) - this needs to update as secondary speakers are added, updated, or removed, but I'm not able to get it to work.

Here is what I have so far:

trigger MultipleSpeakerTrigger on Speaker__c (before delete,before insert, before update) {

Set<ID> parentids = new set<ID>();

for(Speaker__c child : Trigger.new){

parentids.add(child.Multiple_Speakers__c);

}

List<Speaker__c> mainspeaker = new List <Speaker__c>();

mainspeaker = [Select ID, Name, Main_Speaker__r.Speaker_Full_Name__c

from Speaker__c where main_speaker__c = null and id in :parentids];

List<Speaker__c> childspeaker = new List <Speaker__c>();

childspeaker = [Select ID, Name, Main_Speaker__r.Speaker_Full_Name__c,Main_Speaker__c

from Speaker__c where main_speaker__c != null and id in :parentids];

for(Speaker__c p :mainspeaker){

for(Speaker__c c :childspeaker){

if(!p.Multiple_Speakers__c.containsIgnoreCase(c.Main_Speaker__c)){

p.Multiple_Speakers__c += c.Main_Speaker__c + ';';

}

}}

update mainspeaker;

}

Any assistance is very much appreciated!!

Thanks,

Emily
3 answers
  1. Nov 20, 2015, 1:09 PM
    It's a blank text area that appears in the primary speaker record type.  I'm trying to get it so that all the secondary speakers will show up in that text box.  For example, if Bob Smith has a record type of Primary Speaker, and he has Jane Doe and Phillip Jones speaking with him during his presentation (both record type of Secondary Speaker with Smith tied in the Main_Speaker__c (look up to primary speakers), then Multiple_Speakers__c on Bob Smith's record should show as Jane Doe; Phillip Jones;  If we remove the tie or delete Jane's record, then the Multiple_Speakers__c should just show as Phillip Jones;

    I'm not sure if that makes sense as I'm pretty sure the code doesn't since I messed around with it so much trying to get it to work... Thanks for your response and please let me know if there is anything else I can provide.
0/9000