I am finally getting close with my trigger. I at at the point where I need to take the picklist value from one field and update the same value into a picklist with the same value on an unrelated object. So, Task.Call_Dispositon__c needs to carry over and update CampaignMember.Call_Disposition__c so that they have the same value. Both are picklists. Suggestions on how to do this? I am not certain if when working with the picklists if they return the picklist value id or the text of the picklist field.
trigger CallDispositionOnCampaignMember on Task (before insert) {
list<CampaignMember> myCampaignMembers = new list<CampaignMember>();
myCampaignMembers = [Select ID, Call_Disposition__c From CampaignMember];
list<Task> myTasks = new list<Task>();
myTasks = [Select ID, Campaign_Member_ID__c, Call_Disposition__c From Task Where Campaign_Member_ID__c != null];
map<string,Task> memIDtoTaskMap = new map <string,Task>();
for (Task t: myTasks){
memIDtoTaskMap.put(t.Campaign_Member_ID__c, t );
}
for (CampaignMember a: myCampaignMembers){
if (memIDtoTaskMap.containsKey(a.id)){
list<Task> newTask = new list <task> (myTasks);
newTask = [Select ID, Campaign_Member_ID__c, Call_Disposition__c from Task Where Campaign_Member_ID__c = : a.id];
for (task c: newTask){
if (c.Campaign_Member_ID__c == a.id){
a.Call_Disposition__c = c.Call_Disposition__c;
}
update myCampaignMembers;
}
}
}
}