SPListItem 上的 SPWorkflowCollection 始终为空

发布于 2024-08-28 08:20:42 字数 584 浏览 7 评论 0原文

我遇到与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半世晨晓 2024-09-04 08:20:42

此处范围内的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文