I have failed to figure out some aspects of your code. As a result I have not been able to bulkify the trigger. Try this:
trigger CopyCallNotes on Call__c (before insert, before update) {
public String CurrAcc;
public Id CurrCreatedBy;
for(Call__c c: Trigger.new){
accountIds.add(c.Account__c);
CreatedByIds.add(c.CreatedById;);
CurrAcc = c.Account__c;
CurrCreatedBy = c.CreatedById;
System.debug('CAccount' + c.Account__c);
System.debug('CCreatedBy' + c.CreatedById);
System.debug('CName' + c.Name);
System.debug('CId' + c.Id);
List<Call__c> listaToTrue = new List<Call__c>([select Next_Call_Notes__c from Call__c where Account__c = : CurrAcc and CreatedById = :CurrCreatedBy order by CreatedDate desc LIMIT 2]);
System.debug('ListSize' + listaToTrue.size());
System.debug('Listvalue' + listaToTrue.get(0));
String NCN = string.valueOf(listaToTrue.get(0).Next_Call_Notes__c);
c.Next_Call_Notes__c = NCN;
System.debug('CNCN' + c.Next_Call_Notes__c);
}
}
답변 4개