2011-06-08 90 views
0

我在我的Newform.aspx中有一個PeoplePicker字段,我想在該域中選擇該域的用戶名並在另一個字段中更新。sharepoint新窗體獲取域用戶名從人選擇器

我認爲有一些問題,而使用如下:

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.AfterProperties["AnotherField"] = spUser; 
} 
+0

你能提供更多信息嗎? spUser prolly是typeof字符串,AnotherField屬性呢?任何調試信息? – YvesR 2011-06-08 07:16:07

+0

@YvesR當我從單行文本中獲取信息時,它在AnotherField中更新正常,但不會從peoplePicker..i認爲在從PeoplePicker獲取數據後,我必須轉換爲其他格式 – jam 2011-06-08 07:31:27

回答

1

是, 我覺得有問題。

當我們使用

properties.AfterProperties["PeoplePicker"].ToString(); 

則返回-1作爲一個用戶ID。

所以解決方案可能是。 我們必須首先從上面的值中提取帳戶名稱。
然後需要從該帳戶名稱中檢索用戶。
然後我們可以將它設置爲其他屬性值。

相關問題