sharepoint new form get Domain\Username from people picker
I have a PeoplePicker field in my Newform.aspx where I want to pick Domain\Username of that particular field and update in another field.
I think there is some issue while using as below:
strUser = properties.AfterProperties["PeoplePicker"].ToString();
web.AllowUnsafeUpdates = true;
SPUser spUser = web.EnsureUser(strUser);
spUser = spUser.LoginName; \\This returns Domain\Username
if (properties.AfterProperties["PeoplePicker"] != null)
{
properties.AfterProper开发者_JS百科ties["AnotherField"] = spUser;
}
yes, i think there is issue.
when we use
properties.AfterProperties["PeoplePicker"].ToString();
then it returns -1 as a user id.
So the solution may be.
We must first extract the account name from the above value.
Then need to retrive user from that account name.
Then we can set it to other property value.
精彩评论