copy person & group field value to another person or group field programmatically

Hi 

I have one user list in SharePoint sitecollection1 having User in Title(having simple user name) and UserName in Person or Group type field.

I want to copy this list into my site list with same column names programatically using timer job.

How I can copy the person or Group field from siteColletion1 to person or group field of sitecollection2(my site),

as both column types are same.

Pleas suggest any solution.

February 24th, 2014 1:46am

hi vyanky

use bellow sample code:

SPFieldUserValue userField = new SPFieldUserValue(sourceItem.Web, sourceItem["userFieldInternalName"].ToString() );
                    SPUser newUser = destItem.Web.EnsureUser(userField.LoginName);
                    destItem["userFieldInternalName"] = newUser;
                    destItem.Update();

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2014 5:43am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics