Skip to main content

If

An If node evaluates one condition against each item it receives and routes the item to its True path when the condition is true and to its False path when it is false. Use it to send approved orders to one delivery and every other order to review, to process CSV files differently from other files, or to skip a node for the files that do not need it.

If accepts file items and data items and passes each one on unchanged.

If is one of several ways to select items in an Automation. If you are not sure If is the right node, see Comparing If to Related Features below.

Settings

The node takes one Condition, a TransformScript expression without braces that evaluates to true or false for each item. payload.status == "approved" tests a field of a data item or of a parsed file, and attributes.custom_metadata.as2_from == "Acme-AS2" tests the file's custom metadata. A comparison operator tests a value, and a logical operator combines tests, as in payload.amount > 1000 and payload.currency == "USD".

A condition that reads payload parses the file the same way a Transform node does.

What the Next Node Receives

The nodes on the True path receive the items whose condition was true, and the nodes on the False path receive the rest, unchanged in both cases. An item never takes both paths. When every item in a run takes one path, the nodes on the other path receive no items and are Skipped in run detail, which is the expected result and not an error.

Errors

When the condition cannot be evaluated for an item, that item fails. Error Handling rules on the node determine what happens to a failed item. A condition that is not a valid expression fails at save, and the message gives the position of the failing field in the JSON definition.

Switch and Filter also route or select items by a condition, and Content Validation also checks a file's contents against a rule you write.

If vs. Switch

A Switch node routes each item to one of several named paths, checking its rules in order and using the Default path when none matches. Use If when items split two ways on one condition. Use Switch when items are routed to three or more paths, or when names like east, west, and international are easier to read than a chain of If nodes.

If vs. Filter

An If node passes every item on, each to one of its two paths. A Filter node passes on only the items that match its condition, and the rest are not processed further on that path. Use If when the items whose condition is false still need to be processed, for example moved to a review folder. Use Filter when they need no further processing.

If vs. Content Validation

Content Validation is a criterion on an Expectation. It runs a TransformScript against the files of a delivery window after the window closes, records the failures as Criteria Errors, and marks the Evaluation Invalid, which opens an Incident for a scheduled window. It does not move or route a file. An If node tests each item while the Automation is running and routes it, so a file whose condition is false can be moved to a quarantine folder by the next node. Use Content Validation to record whether a partner's delivery was complete and correct. Use If to act on each file as it is processed. An Expectation and an Automation are used together when the Expectation confirms the delivery and the Automation processes the files.