You need to sign in to do that
Don't have an account?
nilesh walke
Write a trigger to sync Mobile, Fax and Phone field between user and contact record using trigger . if no user exists for Contact record, then do nothing. Note – Create Lookup User field on Contac
public static void syncfields(list<contact> con1){
map<String,contact> contacts=new map<String,contact>();
list<user> userlist=new list<user>();
for(contact con:con1)
{
if(con.phone!=null)
{
contacts.put(con.phone,con);
}
}
list<user> users=[SELECT mobilePhone,fax,phone from user where phone IN:contacts.KeySet()];
for(user uc:users)
{
contact con=contacts.get(uc.phone);
uc.phone=con.Phone;
uc.fax= con.Fax ;
uc.mobilePhone= con.MobilePhone;
userlist.add(uc);
}
if(userlist.size()>0){
update userlist;
}
}
working fine but , that last conditions are not matching showing errors
map<String,contact> contacts=new map<String,contact>();
list<user> userlist=new list<user>();
for(contact con:con1)
{
if(con.phone!=null)
{
contacts.put(con.phone,con);
}
}
list<user> users=[SELECT mobilePhone,fax,phone from user where phone IN:contacts.KeySet()];
for(user uc:users)
{
contact con=contacts.get(uc.phone);
uc.phone=con.Phone;
uc.fax= con.Fax ;
uc.mobilePhone= con.MobilePhone;
userlist.add(uc);
}
if(userlist.size()>0){
update userlist;
}
}
working fine but , that last conditions are not matching showing errors
You can take reference from this below code.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.