Example: Workflow condition builder

Some types of tasks use a condition to decide what they should do. A condition is a comparison between values. A condition is either true or false. The properties forms for these tasks share a common organization to create and edit conditions.

The Condition Builder's purpose is to build a formula in its bottom panel that is either true or false. You build the formula using the Edit and Insert menus at the top of the condition builder, along with the Tasks, Basic Ops and System Function panels.

The Tasks panel allows you to insert task attributes and fields of records into the condition.

The Basic Ops panel allows you to insert operators into the condition.

The System Function panel allows you to insert system defined and user defined functions into a condition.

The following example shows the use of these panels and menus. After this example are more detailed explanations.

The example we will work through is for a workflow to be launched for an Employee record. The example will be to build a condition that is true if a preceding Create workflow task succeeded and if the current time is on or after the date that the employee was hired. When we are all finished, the condition will look like:
Create Record::Success=="SUCCESS" && 
   Start::Employee::Detail::DateHire<=CurrentTime() 
When we first begin building a new condition, the bottom panel of the Condition builder looks like the following figure.
Figure 1. Empty condition
The image is explained in the text.

In the beginning there is no formula. There is just a small gray rectangle in the bottom panel. The Condition Builder puts a gray rectangle before each part of the formula.

When you add a part to the formula, it gets added to the right of the currently selected gray rectangle. You can select a gray rectangle by clicking it. You can tell that a gray rectangle has been selected because it will have a blinking cursor inside of it.

The gray rectangle in an empty Condition Builder is already selected. The first thing we will add to the condition is a reference to the Create Record task's success attribute. To do this, we use the Tasks panel.

We begin by clicking the folder icon next to the name of the Create Record task. Clicking the icon causes the attributes and business objects associated with the task to be displayed under the task. The folder icon changes to an open-folder icon.

The attributes now displayed under the Create Record task include an attribute named Success. Clicking the name Success causes the name of the attribute along with the name of the task to be copied to the condition. The Condition Builder now looks like the following figure.
Figure 2. Condition Builder Success attribute
The image is explained in the text.

When we add the reference to the Success attribute, the Condition builder adds another gray rectangle after what we added. The new rectangle after what we added is automatically selected, so the next thing we add will be to the right of that.

The next thing to add to the condition is ==. The == will compare the value of the Success attribute to whatever we put to the right of the ==. The comparison will be true if the two have the same value or false if they do not.

To add the == click the == in the Basic Ops panel. For a complete list with explanations of the operators in the Basic Ops panel, see "Condition builder operators". Clicking an operator in the Basic Ops panel adds the operator to the condition. After you click the == the Condition Builder looks like the following figure.
Figure 3. Condition Builder ==
The image is explained in the text.

The next thing to do is add the text "SUCCESS" so that the condition can be true if the value of the Create Record task's Success attribute is equal to "SUCCESS". To put a text or number value in a condition, we use the Insert menu at the top of the condition builder.

When you click the Insert menu, its menu items appear. They look like the following figure.
Figure 4. Insert menu
The image is explained in the text.

Clicking the Number menu item allows you to add a Number value to a condition. Clicking the String menu item allows you to add a text value to a condition. Clicking either of these menu items creates a box in the Condition where you can enter a number or text value as appropriate.

To enter a string value into the box that is added when you click the String menu item, click the box and then type the value. After you type the value "SUCCESS", the condition builder looks like the following figure.
Figure 5. Condition Builder string
The image is explained in the text.

The next thing to add to the condition is the operator &&. The && operator is a logical && operator. The and operator is true if the conditions on both sides of the && operator are true.

After we added "SUCCESS" to the condition, the part of the condition that was selected was the box that contains "SUCCESS". The Condition Builder will not allow us to do anything to the condition unless one of the gray boxes is selected. Before we can add the && operator to the end of the condition, we must select the gray box at the end of the condition by clicking it. We then add the && operator by clicking && in the Basic Ops panel.

The next thing we add to the condition is a reference to the DateHire field in the Employee record that was used to launch the workflow. Since the record that was used to launch the workflow is associated with the Start task, click the Start task's folder icon to see the list of things under the Start task. This list includes the Employee record that was used to launch the workflow.

To see what is in the Employee record we click the folder icon next to the name Employee. The Condition Builder now looks like the following figure.
Figure 6. Condition Builder &&
The image is explained in the text.

The list that appears in the Tasks panel under the name of a kind of record is a list of section names. An icon appears next to each section name. If what appears next to a section's name is a document icon, the section is a type of section that the Condition Builder cannot use to access fields.

At the time of this writing, the Condition Builder is unable to access fields in multiple-record smart sections. Most of the sections in the figure that have a document icon are multiple-record smart sections.

If what appears next to a section's name is a folder icon or an open-folder icon, then the Condition Builder is able to access the section's fields. At the time of this writing, there are only two kinds of sections that have a folder icon or an open-folder icon next to their name. Single-record smart sections have one of these icons next to their name.

The other kind of section that has a folder icon or an open-folder icon next to its name really is not a section. The Condition Builder pretends that a business object's fields that are not in a smart section are in a section named General. This artificial General section has a folder icon or an open-folder icon next to its name.

An Employee record's DateHire field is in a section named Detail. To see the Detail section we scroll down to a lower part of the Tasks panel and click the folder icon next to the name of the Detail section. We can now see the name of the DateHire field, so we click it. The Condition Builder now looks like the following figure.
Figure 7. Condition Builder field
The image is explained in the text.

The next thing to add to the condition is a <= that will be used to determine if the value of the DateHire field is before or equal to the current time. We add it by clicking the <= in the Basic Ops panel.

We finish by clicking CurrentTime in the System Function panel. The Condition Builder now looks like the following figure.
Figure 8. Condition Builder done
The image is explained in the text.

The system functions that you can click in the System Function panel are the same system functions that are used for extended formulas. For more information, see Application Building for the IBM TRIRIGA Application Platform: Calculations.

You can access user defined functions by clicking the button labeled User Defined Function. These are the same user defined functions that are used for extended formulas. For more information, see Application Building for the IBM TRIRIGA Application Platform: Calculations.

The operators in a condition are evaluated strictly from left to right, except for parentheses. For example, this is always true:
2 + 3 * 4 == 4 * (3 + 2)

For Integration, 0 is Not Selected and 1 is Selected. For more information on the Integration property, see "Start task".