Top
Top
LibraryEASYProcess Reference ManualProcessesServicesProcessFlowWorkshopBinaryDecision

Binary Decision Overview

Binary Decision is mainly used to compare two values. It performs a test which is determined by the the input and outputs either “True” or “False”. This directs the process flow either to the right or down depending on the result of the test.

Each test is composed of a Left Clause, a Right Clause, and the Operator. Typically this is how that string is broken down into the Binary Decision inputs:

The above example is a Binary Decision with one test. If the Left Clause is equal to the Right Clause, the Binary Decision returns “True”.

Each Binary Decision can contain one or many tests. Each test is separated by an AND/OR operator, which determines the order in which the tests are run. ANDs are always evaluated before ORs. The following diagram explains how multiple tests are handled.


BinaryDecision Use Examples
Binary Decision Components
Binary Decision Common Mistakes
Workshop:ProcessFlowWorkshop
Service:BinaryDecision
Inputs
TestsThis is the container node that contains all the Test nodes. It does not accept any input, but you can Right-Click to add new tests (Test#0, Test#1, etc.). Each test below this node is run when this service runs.

TestTest is a container node which accepts no input, but represents a single test which contribute to the Binary Decision. Each Test node is indexed.

AndOrTakes values: "And" or "Or". This is the logical operator if we are performing more than one test.

LeftClauseThis is the left clause of the comparison equation.

OperatorThis is the operator for our comparison. Example: =, !=, <, >.

TypeThis is the type of the comparison we would like to perform. Example: String, Int, Decimal, Double.

RightClauseThis is the right clause of the comparison equation.

BinaryDecision Use Examples

Binary Decision is mainly used to compare two values. It performs a test which is determined by the the input and outputs either “True” or “False”. This directs the process flow either to the right or down depending on the result of the test.

Simple Binary Decision Use

In this process, we are using GetRequestAttributes to return the page we are on. ToLower converts the entire string to lowercase so we can do our comparisons entirely in lowercase. The binary decision is used to determine if we are on the default page, “default.aspx”. If we are, then we hide sections. If not, the process ends without any further action.

Here is a closer look at that binary decision. We are comparing the output from the ToLower service with the hard coded value “default.aspx”.

‘Type’ is set to ‘String’ because the right clause is a string and should be encased in quotations.  The operator is set to “=” because this is the comparison we want to perform.

Note: the left clause is always treated as a variable. If you wanted it to be a string, you must add your own quotation marks.

Here is the Binary Decision Test that is performed:

Typically this is how that string is broken down into the Binary Decision inputs:

The binary decision logs display the node set referenced in the left clause and does not replace it out for the value used. So, in our example, we can look at the output returned from WorkData/ToLower/OutputString and see its value is not equal to “default.aspx”:

“purchaseorders.aspx” is returned by the “ToLower” Service, so the result of the Binary Decision is “False”. As a result, the process flow is directed to the right and the process is terminated.

Within a “For Each” Loop

In this process we have an inquire service, “GetUserId”, which retrieves all the User Ids.

Then, we’re looping over the results, and comparing it with a field value.

If a Match is found, we are displaying a popup message using “SetWindowAttributes” service. If a match is not found, we’re continuing with the loop iteration and finally ending the process using “Terminate” service.

This is the “BinaryDecision” service in which we are comparing the UserId retrieved by “GetUserId” service to the “UserId” field on our webpage.

We have “=” as the operator and “String” as the data type for this comparison. Note: The Index of the loop is automatically handled by EASYProcess.

This is the output returned by the Binary Decision service. Notice the “[$Index0]” has been automatically added to reference the correct GetUserId node which matches the current iteration of the “For Each” Loop.

Multiple Tests

Within a Binary Decision

Many tests can be added to a Binary Decision and they can be separated within the test via AND or OR. When looking at a complicated Binary Decision Test you should split on the ORs and consider everything between them in parenthesis

ANDs are always evaluated before ORs, so we can group like so:

Here is the test formed by the logic above:

WorkData/Input/CartId and WorkData/Input/CartId != ''

or

WorkData/Input/Id and WorkData/Input/Id != '' and WorkData/Input/Verb != 'DELETE'

or

WorkData/ShoppingCartItem/CartId and WorkData/ShoppingCartItem/CartId != ''

There are some examples that are difficult to express in Binary Decisions which use parentheses in order to evaluate ORs first. In these examples, we can convert them to be logically equivalent and evaluate ANDs first.

For instance:

Within an Evaluate

Often times the logic within a binary decision can get complicated and if you would prefer to do all logic in XSLT, you can use an evaluate with a binary decision to accomplish the same task.

Here is the above logic regarding CartIds passed in. The logic’s purpose was to determine if the CartId was passed in and useable (not blank).

The process canvas will look like an evaluate (containing all the logic) and a binary decision (checking the result of the logic against an expected value). This allows us to use XSLT Ifs and Chooses which can simplify complex logic.

Comparing Numeric Values

A common use for binary decision is to check NoOfRecords returned from a query. For instance we could query to find out how many lines your cart currently has. The following binary decision could be named “Cart Has Items?” and have the test “WorkData/Inquire/NoOfRecords > 0”.

Here is how we would set up that binary decision:

There are actually many tests that can answer the question if the cart has items, but some may capture too narrow of a success window.

Make sure to use the Int type when dealing with numbers. In our example, there is no way for the result to be a decimal, but other cases may result in 0.00 which is not equal to 0. If we are querying for the shipping cost of a cart and the result is 0.00 and we have a binary decision checking for the string “0”, the result will be “False”. It is a good idea to get in a habit of using Int when dealing with numbers.

Checking for True/False Flags

Another common use of binary decisions is to compare a node-set Variable to an expected value (True/False).

Here is how we set up the Binary Decision:

It is a good idea when doing logic like this to protect against various letter cases (TRUE, True, true). This is especially a good idea when the value passed in comes passed in from another process or an API call.

In order to safeguard against this, you can use the EASYProcces ToUpper function.

Using the Left Clause Without a Node-Set Variable

The left clause is always treated as a variable, meaning no quotation marks are added and you cannot select the Type. If you wanted it to be a string, you must add your own quotation marks.

Binary Decision:

Binary Decision Logs:

You could also use the left clause as an int. Since quotation marks are not automatically added, if the value in the left clause is not a node-set variable, it would be treated as an int.

Binary Decision:

Binary Decision Logs:


Binary Decision Components

Switch Yes/No Option

By right clicking the service, we have all the regular right-click options, but a new one is unique to Binary Decisions: “Switch Yes/No”. This options is useful to better organize the process canvas and avoid crossing connection arrows.

Binary Decision Operators

The accepted Binary Decision Operators are available in the right hand side under Recommended Values. This option become available once you have clicked into the Operator input when configuring your Binary Decision.

Equal

The “Equal” operator inserts an Equal sign between the left and right clause.

Test Example: WorkData/Evaluate/OutputString = 'default.aspx'

This means the left clause and right clause must match exactly. This is case sensitive.

Left Clause

Operator

Right Clause

Test Result

Default.aspx

=

default.aspx

False

default.aspx

=

default.aspx

True

1

=

1

True

1

=

2

False

test

=

testtest

False

Not Equal

The “Not Equal” operator inserts a “!=” between the left and right clause.

Test Example: WorkData/Evaluate/OutputString != 'default.aspx'

The test performed with this operator is the inverse of the test with a “Equal” operator. For the test to return True, the left side must not match the right side. This is case sensitive.

Left Clause

Operator

Right Clause

Test Result

Default.aspx

!=

default.aspx

True

default.aspx

!=

default.aspx

False

1

!=

1

False

1

!=

2

True

Greater Than Equal

The “Greater Than Equal” inserts a “>=” sign between the left and right clause. This operator is intended to be used with numeric values. A node set value can still be used in the left clause, but it should evaluate to a numeric value for the result to be meaningful.

Test Example: 10 >= 9

WorkData/Evaluate/OutputString >= 9

Left Clause

Operator

Right Clause

Test Result

10

>=

9

True

10

>=

10

True

10

>=

20

False

Greater Than

The “Greater Than” inserts a “>” sign between the left and right clause. This operator is intended to be used with numeric values. A node set value can still be used in the left clause, but it should evaluate to a numeric value for the result to be meaningful.

Test Example: 10 > 9

WorkData/Evaluate/OutputString > 9

Left Clause

Operator

Right Clause

Test Result

10

>

9

True

10

>

10

False

10

>

20

False

Less Than Equal

The “Less Than Equal” inserts a “<=” sign between the left and right clause. This operator is intended to be used with numeric values. A node set value can still be used in the left clause, but it should evaluate to a numeric value for the result to be meaningful.

Test Example: 10 <= 20

WorkData/Evaluate/OutputString <= 20

Left Clause

Operator

Right Clause

Test Result

10

<=

9

False

10

<=

10

True

10

<=

20

True

Less Than

The “Less Than” inserts a “<” sign between the left and right clause. This operator is intended to be used with numeric values. A node set value can still be used in the left clause, but it should evaluate to a numeric value for the result to be meaningful.

Test Example: 10 < 20

WorkData/Evaluate/OutputString < 20

Left Clause

Operator

Right Clause

Test Result

10

<

9

False

10

<

10

False

10

<

20

True

Starts With

The “Starts With” operator rearranges the test to use the XSLT “starts-with” function. This is case sensitive.

Test Example: starts-with(WorkData/Evaluate/OutputString,'test')

Left Clause

Operator

Right Clause

Test Result

Internal_Administrator

starts-with

Internal

True

10

starts-with

1

True

Paul.Johnson

starts-with

paul

False

Contains

The “Contains” operator rearranges the test to use the XSLT “contains” function. This is case sensitive.

Test Example: contains('Paul.Johnson','aul')

Left Clause

Operator

Right Clause

Test Result

Internal_Administrator

contains

Admin

True

Paul.Johnson

contains

John

True

Paul.Johnson

contains

john

False

Binary Decision Types

The accepted Binary Decision Types are available in the right hand side under Recommended Values. This option become available once you have clicked into the Type input when configuring your Binary Decision.

String

Selecting the “String” Type wraps the RightClause value in quotation marks to make it a string. This means your Right Clause should not contain its own quotation marks.

Binary Decision

Binary Decision Logs

Int

Selecting “Int” Type does not add any quotation marks and assumes the RightClause value is numeric. Adding a string in the RightClause value with Type set to Int will not produce a meaningful result.

Binary Decision

Binary Decision Logs

Binary Decision Right Clause Special Values

The Binary Decision Right Clause Special Values are available in the right hand side under Recommended Values. This option become available once you have clicked into the RightClause input when configuring your Binary Decision.

*BLANKS

Set “Type” to “String” and put “*BLANKS” in the RightClause to check if the LeftClause is equal to an empty string.

Test Example: WorkData/Evaluate/OutputString = ''

Set “Type” to “String” and put “ ” in the RightClause to check if the LeftClause is equal to a single space.

Test Example: WorkData/Evaluate/OutputString = ' '

*EXISTS

Putting “*EXISTS” in the RightClause reorganizes the test to check for the existence of the LeftClause node-set variable. To get a meaningful result, the LeftClause must contain a node-set variable. The test is True if the node-set variable in the LeftClause has run before this binary decision and exists in the logs.

Test Example: WorkData/Evaluate/OutputString

Binary Decision

Process Logs

Binary Decision Logs

*NOTEXISTS

Putting “*NOTEXISTS” in the RightClause reorganizes the test to check for the non-existence of the LeftClause node-set variable. To get a meaningful result, the LeftClause must contain a node-set variable. The test is True if the node-set variable in the LeftClause has not run before this binary decision and does not exist in the logs.

Test Example: not(WorkData/Evaluate/OutputString)

Binary Decision

Process Logs

Binary Decision Logs

Binary Decision AndOr

The Binary Decision AndOr Valid Values are available in the right hand side under Recommended Values. This option become available once you have clicked into the AndOr input when configuring your Binary Decision.

If the AndOr value is left blank, it defaults to “And”. In this example the AndOr was left blank between the two tests, so it defaults to “And”.

Binary Decision

Binary Decision Logs

AND

If there are two tests and an “And” exists between them, both tests must be true in order for the binary decision to evaluate True. This is explained in the Truth Table below. This maps out all possible T (True) or F (False) possibilities between the two tests and how that affects the overall test which depends on both Test1 and Test2.

OR

If there are two tests and an “Or” exists between them, only one test needs to be true in order for the binary decision to evaluate to True. This is explained in the Truth Table below. This maps out all possible T (True) and F (False) possibilities between the two tests and how that affects the overall test which depends on both Test1 and Test2.


Binary Decision Common Mistakes

Not using a Wide Enough Success Window

Binary Decision is often used after an inquire to check if values were returned. We often want to check “Were any results returned?” or “Were no results returned?” which can both be configured. When doing so, it is important you think about all possible results.

In the following example, an Inquire returns the number of results and a binary decision check if more than one result was returned. This was taken from the forgot password feature, so it is assumed the value typed in is a valid user email address. However, if the user mistyped their email address or is mistaken which one is associated to their account, the following case can occur.

The inquire runs and the NoOfRecords returned is 0.

However, the process is not set up to handle this case and assumes there can either be 1 result or more than one. Below is the binary decision:

As a result, the binary decision returns true, indicating that the entered email address belongs to multiple User Ids. Instead the the email address typed does not belong to any User Id.


Powered by EASYProcess (© 2019 K-Rise Systems, Inc).