Altova FlowForce Server 2025 Advanced Edition

A Choose step allows you to define conditions under which steps within the Choose block will be executed. You can define any number of conditional steps. Within any When/Otherwise pair, FlowForce Server executes only the condition that is true; the other condition is ignored.

 

Depending on your business needs, you can create Execution steps, For-Each, Error/Success Handling, and Postpone blocks inside a Choose block. You can also nest other Choose blocks inside your Choose block.

 

Structure of a Choose block

The Choose block has the following structure:

 

When {expression}

 Execute (step)

Otherwise

 Execute (step)

 

Some of the possible scenarios of using Choose blocks are described below.

 

Multiple When expressions

The Choose block can contain multiple When expressions (see code listing below). In such scenarios, FlowForce Server executes the first When expression that is true and exists the Choose block. Even if other When expressions are also true, they will not be executed.

 

When {expression}

 Execute (step)

When {expression}

 Execute (step)

When {expression}

 Execute (step)

Otherwise

 Execute (step)

 

Nested When expressions

Under each Choose step, you can nest other Choose steps (sub-conditions), for example:

 

When {expression}

 When {expression}

         Execute (step)

 Otherwise

         Execute (step)

Otherwise

 Execute (step)

 

Choose step in a job

The code listing below shows how a Chose block is integrated into the job. The job has steps A, B, C, D, E, and F. Steps C and D are part of the Choose block. After Step B has been executed, Step C or D will be executed, depending on the When expression. If the When expression returns true, Step C will be executed. Otherwise, Step D will be executed. After Step C or D has been executed, the job proceeds to Step E and then Step F.

 

Step A

Step B

When {expression}

  Execute Step C

Otherwise

  Execute Step D

Step E

Step F

 

Example

The job shown below checks the numeric value of the temperature input parameter that defines whether the weather is hot or normal. The When statement in the Choose block will compute It is boiling hot! if the value of the temperature parameter is greater than 35. Otherwise, the string It is alright will be computed. For simplicity, we have set the default value of the temperature parameter to 36. Therefore, the job will return the It is boiling hot! string.

 

If you intend to pass the result of a Choose step to another step or declare the result to be of a particular type, ensure that the When and Otherwise conditions have the same return type. Otherwise, validation errors might occur.

fs_conditional_job

 

© 2018-2024 Altova GmbH