You need to sign in to do that
Don't have an account?
nilesh walke
need test class for it
public static void syncfields(list<contact> con1){
map<id,contact> contacts=new map<id,contact>();
list<user> userlist=new list<user>();
for(contact con:con1)
{
if(con.User__c!=null){
contacts.put(con.User__c,con);//create lookup field inside the contact which look up with user...
}
}
list<user> users=[SELECT mobilePhone,fax,phone from user where id IN:contacts.KeySet()];
for(user uc:users)
{
if(contacts.get(uc.id).phone!=null){
uc.phone=contacts.get(uc.id).phone;
}
if(contacts.get(uc.id).Fax!=null){
uc.fax= contacts.get(uc.id).Fax ;
}
if(contacts.get(uc.id).MobilePhone!=null){
uc.mobilePhone= contacts.get(uc.id).MobilePhone;
}
userlist.add(uc);
}
if(userlist.size()>0){
update userlist;
}
}
map<id,contact> contacts=new map<id,contact>();
list<user> userlist=new list<user>();
for(contact con:con1)
{
if(con.User__c!=null){
contacts.put(con.User__c,con);//create lookup field inside the contact which look up with user...
}
}
list<user> users=[SELECT mobilePhone,fax,phone from user where id IN:contacts.KeySet()];
for(user uc:users)
{
if(contacts.get(uc.id).phone!=null){
uc.phone=contacts.get(uc.id).phone;
}
if(contacts.get(uc.id).Fax!=null){
uc.fax= contacts.get(uc.id).Fax ;
}
if(contacts.get(uc.id).MobilePhone!=null){
uc.mobilePhone= contacts.get(uc.id).MobilePhone;
}
userlist.add(uc);
}
if(userlist.size()>0){
update userlist;
}
}
Try Below Code Please Mark This As The Best Answer. If It Helps
Thank You!
All Answers
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.
You can also use this test class:-
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks and Regards
Suraj Tripathi.
Please use below code:
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Try Below Code Please Mark This As The Best Answer. If It Helps
Thank You!
and @mukesh gupta thanks and @Suraj thanks :
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; User u = new User(Alias = 'standt', Email='standarduser@testorg.com', EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id, TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com', mobilePhone = '888888888',fax = '444444444',phone = '545454465'
i might thinking that this data is not mandatory for test the class !
?
is it true let me know!?
you have SOQL query on user object in main class that's why you need to insert user from test class and profile is mandatory on user creation time that's why i have used
please let me know what is your test class code coverage. please share screen shot of running test class.
so Please always focus on concept.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Please consider on below code
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh