I'm setting up an Apex trigger and want to access the description values of the old records before a merge. Once I have the 3 description values, I want to combine all the descriptions together during the merge instead of keeping one.
This is what I have so far. Code after each // is sudo code. Am I close?
trigger MergeLeadDescriptions on Lead (before delete, after delete) {
if (Trigger.isBefore) {
Trigger.oldMap.keySet()
// String a = oldMap.id1.Description
// String b = oldMap.id2.Description
// String c = oldMap.id3.Description
}
// MasterRecordId.Description = a + " " + b + " " + c
}
Here are docs on the process of triggers and merging.
I'm having a hard time understanding them..
Thanks!
Update:
This code seems to be working except for the very end...
trigger MergeLeadDescriptions on Lead (before delete, after delete) {
String a, b, c;
if (Trigger.isBefore) {
a = Trigger.Old[0].Description;
b = Trigger.Old[1].Description;
c = Trigger.Old[2].Description;
}
else {
Trigger.old.MasterRecordId.Description = a + ' ' + b + ' ' + c;
}
}
I'm getting an error "Initial term of field expression must be a concrete SObject: List"