...
In this
...
article
Table of Contents | ||||
---|---|---|---|---|
|
...
Snap type:
Transform
...
Description:
...
Overview
You can use this Snap to mimic an IF statement in most programming languages. Each row of the conditional table is equivalent to an if/else if block in an if statement. The default value property is equivalent to the else block of an if statement. Similar to an if statement, the first
...
condition that evaluates to true
...
has its value set into the provided target path. No other
...
conditions are evaluated after one condition evaluates to true. If
...
no conditions evaluate to true, then the default value (if set)
...
is written to its provided target path. However, the Snap
...
evaluates all
...
conditions and
...
writes return values to the
...
Condition's corresponding target path if the
...
Evaluate all property is set.
...
Conditions and return values
...
are created using the expression language defined here.
...
Info |
---|
If |
...
no condition is set, no data can flow through. |
Snap Type
Conditional Snap is a TRANSFORM-type Snap that mimics an IF statement, evaluates conditions, and writes return values to the target path.
Prerequisites
...
...
None
...
.
Support
...
for Ultra Pipelines
Works in Ultra Pipelines
...
Accounts are not used with this Snap.
...
Input | This Snap has exactly one document input view. |
---|---|
Output | This Snap has exactly one document output view. |
Error | This Snap has at most one document error view and produces zero or more documents in the view. |
...
Settings
Label
...
.
Limitations and Known Issues
None.
Snap Views
Type | Format | Number of Views | Examples of Upstream and Downstream Snaps |
---|---|---|---|
Input | Document |
|
|
Output | Document |
|
|
Error | Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:
Learn more about Error handling in Pipelines. |
Snap Settings
Info |
---|
|
Field Name | Field Type | Description | |
---|---|---|---|
Label* Default Value: Conditional | String | Specify the name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your |
...
Pipeline. | |
Evaluate all |
...
Default Value: Deselected | Checkbox | Select this checkbox to evaluate all the conditions and writes all the return values to the target paths if the |
...
conditions evaluates to true. |
Example with Evaluate All true :
For example, select this checkbox, and select the condition as specified below: Conditional expression: $State == "CA" Return value: "California" |
...
Target path: $FullName Conditional expression: $id == 1 |
...
Return value: "found" |
...
$status
Target path: $status If the input document has the following values:
|
...
then the output document displays as below:
because both |
...
conditions evaluate to true. |
...
Null-safe access |
...
Checkbox | Select if you want to set the target value to null in case the source path does not exist. If you do not select this checkbox, then the Snap fails if the source path does not exist |
...
, ignores the record entirely, or writes the record to the error view depending on the setting of the error view property For example, if you set the condition as $person.phonenumbers.pop() |
...
and target as $ lastphonenumber and do not select this checkbox, then it might result in an error in case person.phonenumbers does not exist on the source data. |
...
If you select this checkbox, then this option allows to write null to lastphonenumber |
...
. |
Conditional table |
...
Use this fieldset to specify the if conditions. For example, the following if statement:
|
...
|
...
|
...
|
...
can be given as these conditions: |
...
Condition1 Conditional expression: $State == |
...
"CA" |
...
Example:
Default Value | Default Value Path |
---|---|
"N/A" | $FullName |
is equivalent to:
...
Return value: "California" Target path: $FullName Condition2 Conditional expression: $State == "NJ" Return value: "New Jersey" Target path: $FullName | |||
Conditional expression* Default Value: None. | String/Expression | Specify the Conditional expression in this field based on which the Snap evaluates the condition. | |
Return value Default Value: None. | String | Specify the value for the condition. | |
Target path Default Value: None. | String | Specify the target path to which the return value has to be written. | |
Default value Default Value: None. | String | Specify the default value to assign if none of the conditions evaluate to true, else statement. For example:
|
...
Multiexcerpt include macro | ||||
---|---|---|---|---|
|
...
Multiexcerpt include macro | ||||
---|---|---|---|---|
|
Examples
...
|
...
Default value path Default Value: None. | String | Specify the target path to which the return value has to be written when none of the conditions evaluate to true.
| |
Snap Execution Default Value: Validate & Execute | Dropdown list | Select one of the three modes in which the Snap executes. Available options are:
|