Skip Ribbon Commands
Skip to main content
SharePoint

Create Rule for use in a Join Path Activity to Check if Branches Completed

To Create a Rule for use in a Join Path Activity to Check if Branches Completed

When using a Rule within a Join Path Activity, we want to create a Rule that checks to see if all branches followed previously within the Process have completed before moving on with the rest of the Process.  This type of Rule is especially useful for Processes that may follow 1, 2 or N branches.  For example, let’s look at a Process that splits into 3 branches:

Each of these branches, LinkA, LinkB and LinkC, is associated with a unique Rule, which checks the value of a Solution Data Item called Number, where the Rules are:

          Rule on LinkA: DataItems.Number > 0

          Rule on LinkB: DataItems.Number > 25

          Rule on LinkC: DataItems.Number > 50

Notice that the value of Number will determine how many branches we follow: between 0 and 25, we follow one branch, between 25 and 50 we follow 2 branches and over 50, we follow 3 branches.  When the Process is running, we want to make sure that we wait for the actions within each branch that was followed before moving on with further processing.  Within Join Path Wait on Rule, if we choose “wait on any predecessor activity to complete”, as soon as the first Activity completes, we will continue processing, which can lead to problems if another branch updates information that we need later on, but has yet to complete before we need that information.  However, if we choose “wait on all predecessor activities to complete” and we don’t launch all 3 branches, then Join Path Wait On Rule won’t complete, because at least 1 predecessor activity won’t ever start, let alone complete.

So, we want a way to only check for the completion of those predecessor activities for branches that have been followed.  Fortunately, we can create a Rule for use in the Join Path Activity: Join Path Wait On Rule, that checks to make sure each branch followed has completed its actions before completing the Join Path Activity, by creating a Rule that is the logical equivalent of checking two conditions for each branch: first, that the initial Rule on a link is TRUE, in other words, that the branch has been followed.  And second, that the Activity before the Join path, in other words the predecessor activity, has completed successfully.  Logically, the Rule can be expressed as:

[           (           LinkA is true and ActionA completes successfully   )

Or

[           Not       (LinkA is true)

]

And

[           (           LinkB is true and ActionB completes successfully   )

Or

[           Not       (LinkB is true)

]

And

[           (           LinkC is true and ActionC completes successfully   )

Or

[           Not       (LinkC is true)

]

Notice we check 2 conditions for each branch: the branch was followed and the corresponding predecessor Activity completed successfully.  We then add a condition in the Rule to check if the branch was not followed, which ensures that our expression will evaluate to True even when a branch has not been followed.  Each of these dual conditions is connected with an AND to the same series of conditions for the other branches, which allows us to validate the entire set of possible paths followed and activities for the entire Process to confirm that all followed branches have completed successfully.

Example: Let’s make sure this Rule is the logic we want by using our example and setting the value of the Data Item: Number to 40, which causes LinkA and LinkB to be True, but LinkC to be false.  First, let’s assume both ActionA and ActionB have completed successfully.  In our Rule, then:

          [(LinkA is true and ActionA completes successfully) Or [Not (LinkA is true)] evaluates as true because LinkA is true and ActionA has completed successfully.

          [(LinkB is true and ActionB completes successfully) Or [Not(LinkB is true)] also evaluates as true because LinkB is true and ActionB has completed successfully.

          [(LinkC is true and ActionC completes successfully) Or [Not(LinkC is true)] evaluates as true because Not(LinkC is true)

So, our Rule evaluates as True when both ActionA and ActionB have completed successfully, because all three of the above conditions, joined by an AND, evaluate as True.

But, what if ActionA completes but ActionB continues to run, i.e. has yet to complete successfully?  In this case, we want our Rule to evaluate as False, so we wait for ActionB to complete before continuing with further processing.  Let’s look at it with these conditions:

          [(LinkA is true and ActionA completes successfully) Or [Not (LinkA is true)] evaluates as true because LinkA is true and ActionA has completed successfully.

          [(LinkB is true and ActionB completes successfully) Or [Not(LinkB is true)] evaluates as false because LinkB is true but ActionB has yet to complete successfully.

          [(LinkC is true and ActionC completes successfully) Or [Not(LinkC is true)] evaluates as true because Not(LinkC is true)

Once we have a false condition, the entire expression, which is connected by And statements, evaluates as False.

In our example, LinkA and LinkB are True.  Let’s further assume that ActivityA completes before ActivityB.  Note that the Rule within the Join Path Activity is evaluated each time a predecessor Activity completes.  When ActivityA completes successfully, the Rule in Join Path Wait on Rule evaluates to False, because ActivityB has yet to be completed, so the Join Path Activity continues to wait.  Upon completion of ActivityB, the Rule evaluates as True and Join Path Wait On Rule completes.  So, we have created a Rule which checks to see if all branches followed previously within the Process have completed before moving on with the rest of the Process.

Our Rule, then, is logically correct.  Returning to our example, we create a new Rule in BPM Designer, to be used in Join Path Wait On Rule, which will check to see that all running branches have completed.  First, let’s determine the logical statements above:

ActionA completes successfully: Activities.ActionA.State.State = “Completed” And Activities.ActionA.State.Reason = “Successful”

ActionB completes successfully: Activities.ActionB.State.State = “Completed” And Activities.ActionB.State.Reason = “Successful”

ActionC completes successfully: Activities.ActionC.State.State = “Completed” And Activities.ActionC.State.Reason = “Successful”

LinkA is true and ActionA completes successfully: DataItems.Number > 0 And Activities.ActionA.State.State = “Completed” And Activities.ActionA.State.Reason = “Successful”

Not (LinkA is true): Not(DataItems.Number > 0)

LinkB is true and ActionB completes successfully: DataItems.Number > 25 and Activities.ActionB.State.State = “Completed” And Activities.ActionB.State.Reason = “Successful”

Not (LinkB is true): Not(DataItems.Number > 25)

LinkC is true and ActionC completes successfully: DataItems.Number > 50 And Activities.ActionC.State.State = “Completed” And Activities.ActionC.State.Reason = “Successful”

Not (LinkC is true): Not(DataItems.Number > 50)

Now, let’s combine these statements together for each branch with an Or, completing the check for each running branch to complete:

(DataItems.Number > 0 And Activities.ActionA.State.State = “Completed” And Activities.ActionA.State.Reason = “Successful”) Or Not(DataItems.Number > 0)

(DataItems.Number > 25 and Activities.ActionB.State.State = “Completed” And Activities.ActionB.State.Reason = “Successful”) Or Not(DataItems.Number > 25)

(DataItems.Number > 50 And Activities.ActionC.State.State = “Completed” And Activities.ActionC.State.Reason = “Successful”) Or Not(DataItems.Number > 50)

So, we have a statement for each branch and we combine them into a single statement by joining them with an And to complete our Rule:

((DataItems.Number > 0 And Activities.ActionA.State.State = “Completed” And Activities.ActionA.State.Reason = “Successful”) Or Not(DataItems.Number > 0))

And ((DataItems.Number > 25 and Activities.ActionB.State.State = “Completed” And Activities.ActionB.State.Reason = “Successful”) Or Not(DataItems.Number > 25))

And ((DataItems.Number > 50 And Activities.ActionC.State.State = “Completed” And Activities.ActionC.State.Reason = “Successful”) Or Not(DataItems.Number > 50))

We can now select our Join Path Rule within the Activity: Join Path Wait On Rule and we will wait for all branches followed in the Process to complete before moving on to the Activity: End.

Related Topics
Holding a Process at a Join until a Parent Activity Completes
Holding a Process at a Join until all Parent Activities are Complete
Holding a Process at a Join until specific Parent Activities are Complete


Source
BPM Designer Topics > Overview of Activities and Activity Topics > BPM Activities > Join Path
Last modified at 7/31/2020 11:21 AM