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

Update account phone number by contact phone number by account phone number on before update, it is possible or
Update account phone number by contact phone number by account phone number on before update, it is possible or not,
i am trying using berfore update with map, i am not geting
// update AccountPHONE by CONTACT
public Class BeoreupdateAccountPhone{
public static void beforeupdate(map<id,contact>newmap,map<id,contact>oldmap){
set<id> ids= new set<id>();
for(id key:oldmap.keyset()){
contact n1= newmap.get(key);
contact o1= oldmap.get(key);
ids.add(key);
list<account> ac= new list<account>();
list<account> acc=[select phone,(select phone from contacts) from account where id=:ids];
for(account a:acc){
for(contact c:a.contacts){
if(a.phone!= c.phone){
a.phone= c.phone;
// acc.add((c.phone).a.contacts);
acc.add(a);
}
}
}
update acc;
}
}}
i am trying using berfore update with map, i am not geting
// update AccountPHONE by CONTACT
public Class BeoreupdateAccountPhone{
public static void beforeupdate(map<id,contact>newmap,map<id,contact>oldmap){
set<id> ids= new set<id>();
for(id key:oldmap.keyset()){
contact n1= newmap.get(key);
contact o1= oldmap.get(key);
ids.add(key);
list<account> ac= new list<account>();
list<account> acc=[select phone,(select phone from contacts) from account where id=:ids];
for(account a:acc){
for(contact c:a.contacts){
if(a.phone!= c.phone){
a.phone= c.phone;
// acc.add((c.phone).a.contacts);
acc.add(a);
}
}
}
update acc;
}
}}
You should use Trigger There It will update your Account's phone number with Contact's phone number.
I think this is same as your requirement.
Now you have an idea to update Account field by related Contact's now you can mould this logic as your need.
Thanks,
Raju