You need to sign in to do that
Don't have an account?
ajay ambati
problm with after trigger
iam account and contact in account object iam having phonenumber=9999999999 and i need to update all contact mobilephone feild which are accosiated particular account i done with follwing code no error bt trigger not firing pls hlp....
trigger accountupdatetrigger on account (after update) {
if(trigger.isafter)
{
if(trigger.isupdate)
{
list<contact> lst = new list<contact>();
list <Account> a = [Select id,Name,phone, (Select id, Contact.FirstName,contact.LastName,contact.MobilePhone from Account.Contacts) From Account where phone ='99999999999'];
for(Account acc1:a)
{
for(schema.Contact cn:acc1.Contacts)
{
// lst.add(cn);
// }
// if(cn.MobilePhone!=null && cn.MobilePhone==null)
// {
cn.MobilePhone ='99999999999';
update cn;
}
}
}
}
}
trigger accountupdatetrigger on account (after update) {
if(trigger.isafter)
{
if(trigger.isupdate)
{
list<contact> lst = new list<contact>();
list <Account> a = [Select id,Name,phone, (Select id, Contact.FirstName,contact.LastName,contact.MobilePhone from Account.Contacts) From Account where phone ='99999999999'];
for(Account acc1:a)
{
for(schema.Contact cn:acc1.Contacts)
{
// lst.add(cn);
// }
// if(cn.MobilePhone!=null && cn.MobilePhone==null)
// {
cn.MobilePhone ='99999999999';
update cn;
}
}
}
}
}
I see you are trying to update fixed set of Account if yes then please create Apex Batch job for same
1) http://amitsalesforce.blogspot.in/2016/02/batch-apex-in-salesforce-test-class-for.html
If found below issue in your Trigger
1) You are try to update fixed set of acoount record i will recomend you to try Batch job.
2) DML inside For loop Let us know if this will help you