1. Problem
From within an orchestration, you would like to execute different processing based on the evaluation of available information.
2. Solution
A Decide shape is the equivalent of an If...Then...Else
statement in standard programming. It allows you to direct different
processing at runtime based on the evaluation of information. The
following steps outline how to add a Decide shape to an orchestration
and configure it.
Open the project containing the orchestration.
Select the Decide shape from the toolbox, and drag it to the appropriate location within the orchestration.
Select the Decide shape, and update its properties.
Change the default name if desired.
Add a description if desired.
Set
theReport To Analyst property. Leave the property as True if you would
like the shape to be visible to the Visual Business Analyst tool.
Select the rule branch named Rule_1, and update its properties (click it, and set its properties in the Properties window).
Change the default name if desired.
Add a description if desired.
Set
the Report To Analyst property. Leave the property as True if you would
like the shape to be visible to the Visual Business Analyst Tool.
Right-click the ellipsis next to the Expression property, and enter a valid Boolean expression for the rule.
To add an additional rule, right-click the Decide shape, and select New Rule Branch.
NOTE
To delete a branch,
right-click the branch, and select Delete. To delete the Decide shape,
right-click the shape, and select Delete.
3. How It Works
Decide shapes can be used to
complete different processing based on information available at runtime.
The following is a simple example of using and configuring the Decide
shape from within an orchestration. Assume you have a document as
follows:
<Employee>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
<SSN>111-22-3333</SSN>
<State>Washington</State>
<HireDate>1999-05-31</HireDate>
</Employee>
From within an orchestration, you would like to complete different processing under the following scenarios:
The State is "Washington", and an SSN is provided.
The State is "Washington", and no SSN is provided.
The State is not "Washington".
To set up this
different processing based on these three scenarios, you add a Decide
shape to the orchestration and configure two rule branches and the else
branch. For the first rule branch, define the expression to ensure the
state is Washington and that a Social Security number was provided, as
shown in Figure 1.
NOTE
To access schema nodes
from within an orchestration, you must set the nodes as distinguished
fields from within the schema editor.
For the second rule
branch, configure the expression to ensure the state is Washington and
that no Social Security number was provided, as shown in Figure 2.
NOTE
Refer to the BizTalk
help file for a complete list of valid operators in orchestration
expressions. It uses what many refer to as ".NET Lite," which means only
a subset of libraries are available for use.
The else branch will accommodate all other inbound documents where the state is not Washington. Figure 3
shows a completed orchestration with a Decide shape configured as
described in this example. In this example, a document will be sent to
different locations depending on whether the State is "Washington" and whether or not the document contains an SSN. If the State is not "Washington", no document will be sent. It is not required that the branch of a Decide shape contain any actions.