Workflow: Getting one out of two to approve…

Jan 11, 2006 10:16 · 489 words · 3 minutes read captaris captaris workflow

Yesterday a colleague asked me a question about a simple scenario in Captaris Workflow. Here it is: You have a simple workflow with 4 steps. The first leads to two in parallel, then both of those lead to the fourth. The two in parallel are approvers, perhaps of a document. You only need one approval to move forward. By default, Workflow requires approval from both to move forward, so how can you arrange it so only the one approval is required? It all comes down to the Business Rule Action.

First of lets create our test workflow. I drag and drop four webform tasks onto the canvas and name them First Task through Fourth Task. Now link all the tasks as shown:

Now create two webforms. One should just be the basic default form with the submit buttons. For the other, add a pair of radio buttons in the same group, and label them True and False. Create a single XML element called Approved, then bind that to the True Radio Button. Drag and drop the basic webform to the First and Fourth tasks and the other one to the Second and Third tasks. Note that so far we have done NO coding, just drag and drop, and clicking a few times.

If we run the workflow now, nothing special will happen. When we approve the second task, the workflow will wait for the third task to complete, but that’s not what our scenario demanded. So now we need to add an action to both the Second and Third tasks. From the Toolbox, drag and drop the Business Rule Action to the Complete event on those two tasks. Specify that the Business Rule should check to see if the Approved XML element has been set to True. Now here comes our one line of code. Right-click on the canvas and choose the script view. For the code block for the Second Task Complete event, add the following line:


Add the corresponding line for the ThirdTask Complete event as well (OK, there are two lines of code, but it’s pretty much the same line so it doesn’t really count).

Now if we run the workflow and choose False on the Second (or Third Task), the other of the two will have to run. If we choose True, then the other task doesn’t have to run and it goes straight to the Fourth task.

This is a simple use of the Business Rule Action. If you look closely at the action that gets dropped on your canvas, you’ll notice a check mark and an x in that little diamond. Try dragging and dropping another action onto either the check or x. If the Business Rule evaluates to True, then it runs the actions under the check (or in our case, runs our single line of code). Otherwise it runs the actions under the x. Pretty cool and so damned easy…