Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
trigger CopyConToAcc on Contact (after insert) {
List<Id> accIds = new List<Id>();
List<Account> accounts = new List<Account>();
for(Contact c : trigger.new){
accIds.add(c.accountId);
}
for(Account acc : [SELECT Id, Email__c FROM Account WHERE Id IN :accIds]){
for(Contact con: trigger.new){
acc.Email__c = con.Email;
accounts.add(acc);
}
}
if(accounts.size()>0){
Update accounts;
}
}
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Try the below code it works for me:
Trigger: Trigger-Handler: I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi