You need to sign in to do that
Don't have an account?
Salesforce5566
Please help me on this !!!!
how to write test classes for below trigger ?
rigger SameEmailOnAllContacts on Account (after update) { Set<Id> setAccountId = new Set<Id>(); for(Account acc:trigger.new) { if(Trigger.oldMap.get(acc.ID).Email__c != acc.Email__c || Trigger.oldMap.get(acc.ID).phone != acc.phone) { setAccountId.add(acc.id); } } List<Contact> lstContact = new List<Contact>(); for(Account acc:[Select id,Email__c,(select id,Email from Contacts) from Account where Id in:setAccountId]) { for(Contact con:acc.contacts) { if(con.Email != acc.Email__c) { con.Email = acc.Email__c; lstContact.add(con); } } } if(lstContact.size() >0) { update lstContact; } }
Please help me on this !!!!
@isTest public class SameEmailOnAllContactsTest{ public static testMethod void Test() { Account acct=new Account(); acct.name='a'; acct.industry='Electronics'; insert acct; Contact ct = new Contact(); ct.LastName ='Hoal'; insert ct; } }
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
All Answers
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