You need to sign in to do that
Don't have an account?

how to write TEST class for this trigger.plz check and help testclass code
trigger ContactPhone on Account (Before update)
{
List<Contact> listConForPhoneUpdate;
for (Account acc : Trigger.New)
{
listConForPhoneUpdate = [Select Phone from Contact where phone!=null and AccountID =: acc.id];
for(Contact con : listConForPhoneUpdate )
con.Phone = acc.Phone;
}
update listConForPhoneUpdate;
}
{
List<Contact> listConForPhoneUpdate;
for (Account acc : Trigger.New)
{
listConForPhoneUpdate = [Select Phone from Contact where phone!=null and AccountID =: acc.id];
for(Contact con : listConForPhoneUpdate )
con.Phone = acc.Phone;
}
update listConForPhoneUpdate;
}
https://developer.salesforce.com/blogs/developer-relations/2015/01/apex-best-practices-15-apex-commandments.html
You can optimize your trigger like this :
All Answers
https://developer.salesforce.com/blogs/developer-relations/2015/01/apex-best-practices-15-apex-commandments.html
You can optimize your trigger like this :