You need to sign in to do that
Don't have an account?
MMuneee
Scenrio: Trigger to update account phone number with contact phone numbaer
here am getting error like"Error: Invalid Data. Review all error messages below to correct your data. Apex trigger phupdate caused an unexpected exception, contact your administrator: phupdate: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.phupdate
trigger phupdate on Contact (after insert,after update) {
List<account> li=new list<Account>();
for(Contact c: trigger.new)
{
Account a=[select Phone from account where id=:c.Accountid ];
a.Phone= c.MobilePhone;
li.add(a);
}
update li;
}
trigger phupdate on Contact (after insert,after update) {
List<account> li=new list<Account>();
for(Contact c: trigger.new)
{
Account a=[select Phone from account where id=:c.Accountid ];
a.Phone= c.MobilePhone;
li.add(a);
}
update li;
}
An account can have multiple contacts. Then which contact's phone you want to update on Account phone number. Please describe your requirment in detail so we can give you right solution.
Thanks,
Shiv