function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AzusfdcAzusfdc 

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;
        }           
    }
    
    
}

 
Nayana KNayana K
Trigger updatetrigger on Account(after update)
{
    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;
}
}
}