如何实现并行审批流程中的拒绝?

发布于 2024-07-11 21:30:19 字数 576 浏览 5 评论 0原文

我开发了一个带有复制器活动的 SharePoint 工作流,以便为每个审批者复制自定义活动。 自定义活动为特定用户实现审批分支。 它具有 CreateTask、While、OnTaskChanged 和 CompleteTask 活动的经典形式。

我在复制器上设置 UntilCondition,以便在一位审批者选择拒绝审批后取消执行,然后工作流程完成。 该问题发生在其他未完成的任务上,这些任务在当前状态下“挂起”。 用户打开任务时看不到此状态。

我将 UpdateAllTask​​s 放在替换器之后,以将任务状态设置为“已取消”。 但由于 CompleteTask(对于被拒绝的任务)和 UpdateAllTask​​s 之间没有事件活动,因此对于被拒绝的任务,UpdateAllTask​​ 活动也设置为 Canceled。

问题是,我该怎么做才能在 UpdateAllTask​​s 之前刷新 CompleteTask 所做的挂起更改?

或者,也许还有另一种方法来实现这样的工作流程。 我正在考虑如何使用 UpdateTask 为自定义活动实现取消处理程序。 但我不知道如何实现它并告诉取消处理程序它在拒绝的情况下执行。

I develop a SharePoint workflow with a Replicator activity to replicate a custom activity for every approver. The custom activity implements an approval branch for a particular user. It has classic form with CreateTask, While, OnTaskChanged and CompleteTask activities.

I setup UntilCondition on the replicator to cancel execution after one approver chooses to reject the approval and then workflow finishes. The problem happens with other uncompleted tasks which "hang" in their current state. User does not see this state when open the task.

I put UpdateAllTasks after the replacator to set the task status to Cancelled. But since there is no event activities between CompleteTask (for the rejected task) and UpdateAllTasks, the UpdateAllTask activity set Cancelled for the rejected task also.

The question, what can I do to flush the pending change made by CompleteTask before UpdateAllTasks?

Or perhaps, there is another way to implement such workflow. I was thinking about the way to implement Cancel handler for the custom activity with UpdateTask. But I do not know how to implement it and tell to the cancel handler that it executes in the case of the rejection.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

栀梦 2024-07-18 21:30:19

在面临同样的问题并花费大量时间研究和尝试不同的选择之后,我认为我找到了一个非常好的解决方案。 我将其发布在这里供后代使用。

  1. 创建一个名为 ReviewActivity 的扩展 SequenceActivity 的自定义活动。
  2. ReviewActivity 包括典型的 CreateTask -> 。 同时-> OnTaskChanged ->; CompleteTask 场景
  3. 在我的工作流程中,我有一个 Replicator,它正在创建 ReviewActivity 的许多实例(以及许多任务)。
  4. 复制器实现了一个 UntilCondition 来检查任务是否被拒绝(这是在 ChildCompleted 中设置的)
  5. 在复制器之后,我有一个 UpdateAllTask​​s 来关闭剩余的任务

如果您对这种情况有任何经验,那么您已经准备好了告诉我 UpdateAllTask​​s 还会更新最初被拒绝的任务,因为“CompleteTask”尚未保存到数据库中。 神奇之处在于您可以为自定义活动 (ReviewActivity) 定义一个名为 PersistOnClose 的属性。

[Designer(typeof(ActivityDesigner), typeof(IDesigner))]
[PersistOnClose]
public partial class ReviewActivity : SequenceActivity

此属性可确保 ReviewActivity 完成后,所有更改都将保存到数据库中。 由于 ReviewActivity 中的最后一个活动是“CompleteTask”,因此该任务将保存到数据库中。 因此,UpdateAllTask​​s 不会触及它。

我希望这可以帮助别人。

After being faced with the same problem and spending a lot of time researching and trying out different options, I think I found a really good solution. I'm posting it here for posterity.

  1. Create a custom activity that extends SequenceActivity called ReviewActivity
  2. The ReviewActivity includes the typical CreateTask -> While -> OnTaskChanged -> CompleteTask scenario
  3. In my workflow, I have a Replicator that is creating many instances of the ReviewActivity (and thus many Tasks).
  4. The replicator implements an UntilCondition that checks to see if a task was rejected (this is set in the ChildCompleted)
  5. After the Replicator, I have an UpdateAllTasks to close the remaining tasks

If you have any experience with this scenario at all, you are getting ready to tell me that UpdateAllTasks also updates the originally rejected task since the "CompleteTask" has not been persisted to the database yet. The magic is in an attribute that you can define for the custom activity (ReviewActivity) called PersistOnClose.

[Designer(typeof(ActivityDesigner), typeof(IDesigner))]
[PersistOnClose]
public partial class ReviewActivity : SequenceActivity

This attribute ensures that once the ReviewActivity is complete, all changes are persisted to the database. Since the last activity in the ReviewActivity is the "CompleteTask", the task is saved to the DB. Therefore, the UpdateAllTasks will not touch it.

I hope this helps someone.

不乱于心 2024-07-18 21:30:19

您是否尝试在完成任务和 updatealltasks 活动之间放置代码活动?

Did you try putting a code activity between the complete task and updatealltasks activity?

久夏青 2024-07-18 21:30:19

按以下方式构建您的活动:
创建任务-> OnTaskChanged ->; If/Else 活动(如果批准者决策为“拒绝”,则将条件设置为 true)-> (在 If 分支内)UpdateAllTask​​s Activity(在 Activity 属性中将状态设置为取消)-> (在 If 分支之外)CompleteTask 活动。

当审批者决定拒绝某个任务时,WF 将取消所有任务。 它还将取消拒绝者的任务,但在“CompleteTask”活动将触发并将相应的任务设置为“已完成”之后。

Struct your activities as the following:
Create Task - > OnTaskChanged -> If/Else Activity (set the condition true if the approver decision was "reject") -> (Inside the If branch) UpdateAllTasks Activity (set the status to cancel within the Activity properties) -> (Outside the If branch) CompleteTask Activity.

When an approver decides to reject a task, the WF will cancel all the tasks. It will also cancel the task of the person who rejected but right after the "CompleteTask" activity will fire and set the corresponding task as Completed.

情话难免假 2024-07-18 21:30:19

我今天遇到了类似的问题。 我解决了这个问题:

  1. 如果任务被取消(基于字段完成和百分比完成),则在 ontaskchanged 方法中将变量 taskCancelled 设置为 true ,
  2. 仅当 taskCancelled 变量为 true 时, updateAllTask​​s 方法运行以在每个 ontaskchanged 事件之后取消每个任务(按复制器内的顺序)
  3. 如果 taskCancelled 变量为真,则将复制器的直到条件设置为真

I was faced with a similar problem today. I solved it with:

  1. setting variable taskCancelled to true inside ontaskchanged method if the task was cancelled (based on field completed and percentageCompleted)
  2. updateAllTasks method run to cancel every task after every ontaskchanged event (in a sequence inside replicator) only if taskCancelled variable was true
  3. setting until condition for replicator to true if taskCancelled variable was true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文