SPListItem 上的 SPWorkflowCollection 始终为空
我遇到与 Sharepoint 工作流程和关联任务列表相关的问题。
我有两个为我们的产品创建的自定义工作流程。它们都使用相同的任务列表,该列表具有从任务内容类型继承的自定义内容类型。
现在我遇到一个情况,正在运行的工作流程已通过列表或文档被删除,这会导致孤立任务。
我想覆盖任务列表 OnDeleting 事件,以便用户可以清理他们的任务,使其不包含不必要的孤立任务。所以我的项目删除看起来像这样
public override void ItemDeleting(SPItemEventProperties properties)
{
SPListItem currentListItem = properties.ListItem;
}
问题是,当我进入调试模式并检查 currentListItem.Workflows.Count 字段时,它始终为 0。无论我启动哪个工作流程或查看哪个任务,SPWorkflowCollection 都会返回总是空的:(
我想知道这是否可能与我们的自定义工作流程中的错误有关,其中它没有正确连接(但它正确完成并且当工作流程终止时任务被删除)或者我是否以错误的方式看待这个问题?
I'm having a problem relating to Sharepoint workflows and the associated task list.
I have 2 custom workflows that we created for our product. They both use the same Task list that has a custom content type that inherits from the Task content type.
Now I have a case where a running workflow has been deleted via the list has been deleted or the document, this results in orphaned tasks.
I want to overwrite the Task lists OnDeleting event, so that users can cleanup their tasks so that it won't contain unneccessary orphaned tasks. So my item deleting looks like this
public override void ItemDeleting(SPItemEventProperties properties)
{
SPListItem currentListItem = properties.ListItem;
}
The problem is that when I go into debug mode and check the currentListItem.Workflows.Count field then it's always 0. It doesn't matter which workflow I initiate or what task i look at, the SPWorkflowCollection returned is always empty :(
I was wondering if this might be related to a bug in our custom workflow where it's not wired up properly (but it finishes correctly and tasks are deleted when a workflow is terminated) or am I looking at this the wrong way ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此处范围内的
currentListItem
是任务项本身,而不是工作流正在运行的列表项。该任务没有针对其运行的工作流,因此预期计数为零。如果您尝试访问与要删除的项目上的工作流程关联的工作流程任务,则需要在工作流程激活的每个列表(而不是任务)上使用这种事件处理程序列出工作流用于存储其任务的列表。
The
currentListItem
you have in scope here is the task item itself, not the list item that the workflow is running against. The task doesn't have a workflow running against it, so the zero count is expected.If you're trying to get to the workflow tasks associated with workflows on an item you're deleting you'd need this kind of event handler on each list the workflow is activated on, not on the tasks list the workflow uses to store its tasks.