开发者

sharepoint new form get Domain\Username from people picker

开发者 https://www.devze.com 2023-03-11 22:42 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消