Conditional

On this Page

Snap type:

Transform


Description:

This Snap mimics 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 conditional that evaluates to true will have its value set into the provided target path. No other conditionals will be evaluated once one evaluates to true. If no conditionals evaluate to true, then the default value (if set) will be written to its provided target path. However, the Snap will evaluate all conditionals and write return values to the Conditional's corresponding target path if the evaluate all property is set.

Conditionals and return values can be created using the expression language defined here.

Prerequisites:

[None]


Support and limitations:Works in Ultra Pipelines.
Account: 

Accounts are not used with this Snap.


Views:
InputThis Snap has exactly one document input view.
OutputThis Snap has exactly one document output view.
ErrorThis Snap has at most one document error view and produces zero or more documents in the view.

Settings

Label



Required. 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



Required. Evaluates all the conditionals and writes all the return values to the target paths if the conditional evaluates to true.

Example with Evaluate All true :

 ConditionalReturn Value Target Path
 $State == "CA""California" $FullName
 $id == 1 "found" 

 $status



For an input document:


would return a document


because both conditionals evaluate to true.

Default value: Not selected


Null-safe access


Enabled: Lets you set the target value to null in case the source path does not exist, such as $person.phonenumbers.pop() ->$ lastphonenumber can result in an error in case person.phonenumbers does not exist on the source data. Enabling this allows to write null to lastphonenumber instead. 
Disabled: Fails if the source path does not exist or ignores the record entirely or writes the record to the error view depending on the setting of the error view property.


Conditional table
 

Required. Contains the conditional, return value, and target path for a block in the if/else if statement.

Example

 Conditional   Return Value Target Path
 $State == "CA""California" $FullName
 $State == "NJ" "New Jersey"  $FullName


Is equivalent to:
 


Default Value
Default value to assign if none of the conditionals evaluate to true.

Example

 Default ValueDefault Value Path
 "N/A" $FullName


is equivalent to: 


 

Examples


 

Snap Pack History