if a contact has a custom field as amount and account have a custom field total amount roll up the amount field on account if one account associated have two contacts. 1)first contact amount is 20 2)second contact amount is 30 then total amount will display 50 in account
Below is my code. I display contact amount field in account total amount I don't know how to do the rest of the logic. how can i add both contacts amount and display it in account
trigger CopyPhoneOnContact on Contact (before insert) {
List<String> upcon =new List<String>();
List<account> up=new List<account>();
for(contact c:trigger.new)
{
upcon.add(c.accountid);
}
List<account> acc=[select phone from account where id in:upcon];
for(account a:acc)
{
for(contact c:trigger.new)
{
if((a.id).equals(c.AccountId))
{
a.phone=c.Phone;
up.add(a);
}
}
}
update up;
}