1
我正試圖檢索完成任務的persdon的名稱。在我的任務列表中,我可以看到編輯器的「修改者」。
在Sharepoint Manager中,我可以在編輯器列中看到人員名稱。獲取任務修改者
我怎麼能在我創建任務的代碼
得到這個值和ontaskchanged
後,我有一個代碼塊。我嘗試了很多排列,但無法檢索這些數據。
我正試圖檢索完成任務的persdon的名稱。在我的任務列表中,我可以看到編輯器的「修改者」。
在Sharepoint Manager中,我可以在編輯器列中看到人員名稱。獲取任務修改者
我怎麼能在我創建任務的代碼
得到這個值和ontaskchanged
後,我有一個代碼塊。我嘗試了很多排列,但無法檢索這些數據。
private void UpdateCreatedByAndModifiedByFieldData(string strSiteUrl, string strListName, string strUserFieldName)
{
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(strSiteUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[strListName];
foreach (SPListItem listItem in list.Items)
{
//Read user id from a list column of user type and create SPUser object
SPUser user = web.EnsureUser(listItem[strUserFieldName].ToString().Trim());
if (user != null)
{
string userValue = user.ID + ";#" + user.Name;
//Assign the above user to the "Created By" column
listItem["Author"] = userValue;
//Assign the above user to the "Modified By" column
listItem["Editor"] = userValue;
//Call the update method to apply the above changes
listItem.Update();
web.Update();
}
}
}
}
});
}
catch (Exception ex)
{
throw ex;
}
}
入住這也
How to get SharePoint file creator name using AllDocs table?