【发布时间】:2010-07-29 22:56:55
【问题描述】:
我正在为 SharePoint 2007 AfterProperties 苦苦挣扎。我有一个人员输入字段,可以在其中添加几个人。
在 ItemUpdating 事件中,我现在需要确定哪些用户被添加、删除或保持不变。
不幸的是,这变得很困难,因为未触及用户的 id 在 AfterProperties 中变为 -1,因此我无法使用 SPFieldUserValueCollection 来查找用户。
一个例子。 properties.ListItem["AssignedTo"].ToString() 显示:
1;#domain\user1;#2;#domain\user2
properties.AfterProperties["AssignedTo"].ToString() 显示:
-1;#domain\user1;#-1;#domain\user2;#3;#domain\user3
我计划使用以下代码来确定删除和添加的用户:
foreach (SPFieldUserValue oldUser in oldUserCollection)
{
if (newUserCollection.Find(x => x.LookupId == oldUser.LookupId) == null)
{
RemoveRole(aListItem, oldUser.User, roleDefCollection[workerRoleName]);
}
}
foreach (SPFieldUserValue newUser in newUserCollection)
{
if(oldUserCollection.Find(x => x.User.LoginName == newUser.LookupValue) == null)
{
AddRole(aListItem, newUser.User, roleDefCollection[workerRoleName]);
}
}
我如何归档,AfterProperties 显示正确的查找 ID?
【问题讨论】:
标签: sharepoint input userid