You need to sign in to do that
Don't have an account?
Manjunath reddy 6
copy phone from contacts to related accounts phones
I have a requirement to copy phone from contact to related account phone.but my trigger not works, can some one help me on this
I tried to create a trigger on contact also as below but not works.
trigger copy on account(after insert,after update) { List<id> carry=New list<id>(); For(account acc:trigger.new){ carry.add(acc.id); } List<Contact> hold=[select id, name,phone from contact where id IN: carry]; List<account> take=[Select id,phone from account where id IN: carry]; for(account acc:take){ for(contact c:hold){ acc.phone=c.phone; } } }
I tried to create a trigger on contact also as below but not works.
trigger abc on Contact (after insert,after update) { List<id> carry=New list<id>(); For(contact c:trigger.new){ carry.add(c.id); } List<Contact> hold=[select id, name,phone from contact ]; List<account> take=[Select id,phone from account where id IN: carry]; for(account acc:take){ for(contact c:hold){ acc.phone=c.phone; } } }
Try this.
Regards,
Sanpreet