Choice
Discover more about the Choice component and how to use it on the Digibee Integration Platform.
Last updated
Discover more about the Choice component and how to use it on the Digibee Integration Platform.
Last updated
Choice allows flows to take different paths inside a pipeline. It's part of a components set that helps with the integrations organization.
Take a look at the configuration options for the component. Parameters supported by Double Braces expressions are marked with (DB)
.
Parameter | Description | Default value | Data type |
---|---|---|---|
Label | Defines the path name. It must be a unique name that can be repeated in the pipeline. | N/A | String |
Type | Defines the structure of the different path your flow should take (When or Otherwise). Read the Type section to learn more. | When | String |
Type Rule | Defines the language type (Simple or JSON Path), which will be used for the condition declaration (every time When gets chosen in the Type parameter). Read the Type Rule section to learn more. | JSON Path | String |
Condition | Declares the condition used to define if the path must be executed. When the previously defined conditions generate conflict or cause an overlap, only one of them will be executed (every time When gets chosen in the Type parameter). | $ | String |
The configuration parameters will not be available if the component is not connected to other components in the pipeline. Once you connect it properly, just click at the connection point and then in the gear icon to access the parameters as shown in the image detail below:
To work with this component, you must know two structure types of Choice. They're used to create the paths:
When: defines a condition that allows the flow to take a different path towards a specific execution line. You must declare at least one condition.
Otherwise: the structure is executed when none of the When conditions is attended. You must declare at least one condition.
Defines expressions that go through a JSON component to reach a subset. Whenever you use Choice, a match will be made for the path execution.
Imagine that, in the path that comes before Choice, your data flow has the following output:
The following condition declared as When validates the path your flow should take:
Know the other options for the JSON Path declaration:
JSON Path | Description |
---|---|
$ | The object root or array. |
.property | Selects a specific object in the related object. |
['property'] | Selects a specific property in the related object. Be sure to put only single quotes around the property name. Tip: consider this instruction if the property name has specific characters, such as spaces, or begins with a character other than A..Za..z_. |
[n] | Selects the n-th element of an array. The indexes start with 0. |
[index1,index2,…] | Selects array elements with specific indexes and returns a list. |
..property | Recursive descent: searches for a specific property name recursively and returns an array with all the values with this property name. It always returns a list even if only 1 property is found. |
* | Wildcard selects all the elements in an object or array, no matter that their names or indexes are. For example, |
[start:end] / [start:] | Selects elements of a start array and even, although not necessarily, an end array. If the end is omitted, select all the arrays until the end of the array. A list is returned. |
[:n] | Selects the first n elements of the array. A list is returned. |
[-n:] | Selects the last n elements of the array. A list is returned. |
[?(expression)] | Filter expression. It selects all the elements in an object or array that match the specified filter. A list is returned. |
[(expression)] | Script expressions can be used instead of explicit property names or indexes. For example, |
@ | Used for filter expressions to make reference to the current node that is being processed. |
== | Equal to. 1 and '1' are considered the same result. String values must be attached in single quotes (and not in double quotes): |
!= | Different than. String values must be attached in single quotes. |
> | Greater than. |
>= | Greater than or equal to. |
< | Less than. |
<= | Less than or equal to. |
=~ | Compatible with a JavaScript RegEx. For example, |
! | Used to deny a filter. For example, |
&& | Logical AND operator. Example: |
|| | Logical OR operator. Example: |
Read this JSON Path article to learn more about the topic.
It's basically a small and simple language to evaluate expressions and predicates without demanding new dependences or JSON path knowledge.
Imagine that, in the path that comes before Choice, your data flow has the following output:
The condition declared as When validates the path your flow should take:
Know the other options for the Simple declaration:
Simple | Description |
---|---|
== | Equal to. |
=~ | Equal to, case-insensitive when comparing strings. |
> | Greater than. |
>= | Greater than or equal to. |
< | Less than. |
!= | Different. |
!=~ | Different than, case-insensitive when comparing strings. |
regex | Validates if a string matches the specified RegEx. Example: |
&& | Logical AND operator. Example: |
|| | Logical OR operator. Example: |
Example: