A filter decides which records a flow step passes on or accepts, so a flow can process only the orders over a certain amount, skip records from one subsidiary, or send a record to one import but not another. You build a filter from rules in the Filter editor, or write it in JavaScript when the logic is too involved for rules. This article explains the two kinds of filter, how to build one, and what each part of the editor does.
Output filters and input filters
| Filter | Where | What it does to a record that doesn't match |
|---|---|---|
| Output filter | A source step, or any lookup or import that has steps after it | Drops the record. No later step sees it. |
| Input filter | A lookup or import step | Skips this step only. The record continues to the steps after it as if nothing happened. |
A record that a filter excludes isn't an error, so it doesn't appear in the flow's errors. If records are missing from a destination and there's no error, compare the record's field values against the filter's operator and value — including capitalization, formatting, and empty fields — and run the flow again with a sample record. Execution logs show whether a record was evaluated or skipped.
Create a filter
- Go to Build
> Flows, and then open the flow.
- Point to the step, select Actions
, and then select Output filter or Input filter.
- Build the rules described in the next section, or select JavaScript to write the filter as a script.
- Select Preview to check which sample records pass, and then select Save & close.
If a field you want to filter on isn't listed, enter it by name. If your sample record doesn't pass the filter, no sample records reach the later steps while you're building; edit the step's mock output so one record satisfies the rules.
The Filter editor
| Part | What it does |
|---|---|
| NOT | Excludes the records that match the rules instead of including them. |
| AND / OR | AND keeps records that match every rule in the group; OR keeps records that match any rule. |
| Field | The record field to test. The list shows the fields in the sample record; select + Add field to enter one that isn't listed. |
| Operand type | What the field is compared with: a Field from the record, a Value you enter, or an Expression. An expression can be a basic calculation (add, subtract, multiply, divide, replace) or a handlebars expression in {{ }}, for example to trim whitespace, change case, offset a date, or format a number before comparing. Handlebars expressions are evaluated, so a rule that uses {{ }} as literal text doesn't match the way it once did; rewrite such rules. |
| Data type | For field and value operands: string, number, date-time, or Boolean. |
| Operator | equals, not equals, is greater-than, is greater-than or equals, is less-than, is less-than or equals, between (enter a start and an end), ends with, contains, does not contain, null, is not null, matches. |
| + Condition | Adds another rule. |
| Add group | Nests a set of rules with its own NOT/AND/OR — for example, one group that excludes records created before a date and another that includes records matching either of two statuses. |
| Condition handle | Appears when you point to a rule. Drag it to reorder rules. Actions |
Filter with JavaScript
Rules suit most filters. Switch the editor to JavaScript when the filter has to concatenate or parse strings before comparing them, total or average several numeric fields, or compare a date with a number of days ago. A filter uses rules or a script, not both: when the editor is set to JavaScript, any rules you defined are ignored.
The editor inserts the stub function filter (options) { return true } for you to complete. Return true to keep the record or false to drop it. options carries the record, plus pageIndex, lastExportDateTime, currentExportDateTime, settings, testMode, and job. The same stub is under Resources > Scripts > Create script > Insert function stub > Filter. If the script fails, see FAQ: How do I fix JavaScript errors in a filter or hook?.