Convert text to UserField in SharePoint2010
How to convert simple text to userField in SharePoint2010 library? Idea: I uploading specific document in xml format, that contains text field in next format - domain\username (e.g. 'CSIA\ROV'). My library has a field with type UserField (Person or Group) and i want to convert domain\username to this type, that get in result user, that currently logged in sp portal (e.g.开发者_C百科 Roman Vovk). What methods can i use to solve my problem? Can i sovle this problem use sp workflows or sp designer (caml)? Or should i use some event receiver (e.g. ItemAdding)?
I think you need to roll out some code. i.e using an event handler.
The thing is that the user field in SharePoint expects a different format than domain\user. It works on the format 145;#BobR;#11;#Sally
The first thing you need to do is to ensure that your user belongs to the site, then you can get a reference to the SPUser object that represent it and use this to add an entry to the field.
For more details: UserField.Value Property
精彩评论