Skip to main content
Mohd Nabeel (Coforge Limited) 님이 #Apex에 질문했습니다

trigger InsertContact on Account (after insert, after update) {

if( Trigger.isUpdate && Trigger.isAfter){

AccountContact.AccountBillingModify(Trigger.new);

}

}

//Handler class

public class AccountContact{

public static void AccountBillingModify(List<Account> acctList){

Map<Id, Account> accsWithContactMap = new Map<Id, Account>([select id, BillingPostalCode, (select Id, MailingPostalCode from Contacts)

from account

where id in :acctList]);

for (Account acc: acctList){

for(Contact con : accsWithContactMap.get(acc.Id).Contacts){

if(acc.BillingPostalCode != con.MailingPostalCode){

acc.OutofZip__c = true;

}

}

}

}

}

 
답변 3개
  1. 2019년 11월 11일 오전 11:04
    Recursion causing this.. please add one static flag as a class member to avoid recursion.

    Thanks.