Which is the best way to copy item with person column to another site ? Situation: I have source site A and destination site B with the same structured custom list. I have to copy item from A to B. Problem is with field "Boss" - it's person field type. A and B are on the same SP farm, synchronized with the same AD database.

code (simplified, sourceItem is current processing item from A and destItem is newly created item in B):

string sBoss = sourceItem["Boss"].ToString();
SPFieldUserValue user = new SPFieldUserValue(sourceItem.Web, sBoss);
SPUser userdest =   contextdestination.web.EnsureUser(user.User.LoginName);
destItem["Boss"] = userdest;

Everything goes ok, till I am iterating item with Boss value, who is no longer valid in AD. On destItem the value of Bossfield is wrong. On sourceItem field on all views is displayed correctly and have right url to person. No error is fired. Is there some way to handle it , or is my solution totally wrong and must be done other way ?


Does the "Boss" have access to that specific site? I think the EnsureUser method goes in this order:

  • Checks if user has access to site
  • If user does not it validates that the user, then gives access

EnsureUser does validate against AD, so if you really want this to work, I would suggest to enable his/her account, run this command, then disable it again.

EDIT: Alternatively, if the boss is present in the User Information List, I think you may be able to pull it off in this way:

SPFieldUserValue bossFUV = new SPFieldUserValue(destweb, bossID, bossLoginName);

//where bossID = the userID pulled from the User Information List
//where bossLoginName = the LoginName pulled from the User Information List
| improve this answer | |
  • Hi Mike, thanks. How to check if user has access ? Manually is not possible. On site A can be thousands of users (historically).... From where I can take bossID for site B ? The same person has different ID on different sites. – Marian Jul 27 '15 at 14:11
  • You have to look for the "boss" in the User Information List, http://sharepoint/sites/<sitecollection>/_catalogs/users/simple.aspx – Mike Jul 27 '15 at 15:16
  • Hello Mike, I will try it. Thanks a lot for your time. – Marian Jul 28 '15 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.