You need to sign in to do that
Don't have an account?
Azusfdc
Parent to Child Trigger trying to invoke trigger to class below is the code could any body help ?
Trigger updatetrigger on Account (after update) { helperclassnew.idscaputure(Trigger.new); if(Trigger.isupdate) helperclassnew.updatechildrec(); }
public class helperclassnew{ public static void idscaputure(List<account> acclist,Set<Id> acctids,map<Id,Account> mapaccount) { for(account acc:acclist) { acctids.add(acc.id); mapaccount.put(acc.id,acc); } } public static void updatechildrec(list<Contact> listContact,Set<Id> acctids,map<Id,Account> mapaccount) { listContact = [SELECT MailingStreet, MailingCity,Description,AccountId FROM Contact WHERE AccountId IN : acctIds]; if(listContact.size() > 0) { for(Contact con : listContact) { con.Phone= mapAccount.get(con.AccountId).Phone; con.Description= mapAccount.get(con.AccountId).Description; } update listContact; } } }
{
AccountHandler objHandler = new AccountHandler();
If(Trigger.isAfter && Trigger.isUpdate)
objHandler.onAfterUpdate( Trigger.newMap);
}
Class :
public class AccountHandler
{
public AccountHandler(){}
public void onAfterUpdate(Map<Id,Account> mapNewAccount)
{
List<Contact> lstConToUpdate = new List<Contact>();
for(Contact con: [SELECT Phone, Description,AccountId FROM Contact
WHERE AccountId IN : mapNewAccount.keySet()]
{
con.Phone= mapNewAccount.get(con.AccountId).Phone;
con.Description= mapAccount.get(con.AccountId).Description;
lstConToUpdate.add(con);
}
if(!lstConToUpdate.isEmpty())
{
update lstConToUpdate;
}
}
}