You need to sign in to do that
Don't have an account?
Manjunath SC 5
How to write test class for contact creation of new account trigger
Hello guys
i am new to the coding, i want to write test class for contact creation on new account, below is my code
trigger ConOnNewAcc on Account (after insert){
Public List<Contact> con = new List<Contact>();
For(Account Acc:Trigger.new ){
Contact c=new contact();
c.accountid=acc.id;
c.Lastname=acc.Name;
con.add(c);
}
Insert Con;
}
i am new to the coding, i want to write test class for contact creation on new account, below is my code
trigger ConOnNewAcc on Account (after insert){
Public List<Contact> con = new List<Contact>();
For(Account Acc:Trigger.new ){
Contact c=new contact();
c.accountid=acc.id;
c.Lastname=acc.Name;
con.add(c);
}
Insert Con;
}
Greetings to you!
Please try below code:
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
I have gone through your problem, Please try below code:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
I looked at your query. I have created a test class that should work fine in your case.
Here is my code -
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com