SmartFilters & SmartFormulas
SmartFields give you the values in your flow – the customer's number, the response status code, the line amount. SmartFilters and SmartFormulas are how you act on those values: ask a yes/no question, or compute a number.
- A SmartFilter is a boolean expression. It answers a yes/no question. The Decision step's Condition, the Find Records step's Smart Filter – both are SmartFilters.
- A SmartFormula is a math expression. It produces a number. You drop one inside a text field by wrapping it in
[[ … ]], and the result replaces the placeholder when the step runs.
Both pick up SmartField tokens ({{customer.no}}, {{httpRequest.statusCode}}, …) the same way every other configuration field does. The token is resolved first; the operator or formula then runs on the resolved text or number.
SmartFilters
A SmartFilter is a single boolean expression made up of comparisons, joined with & (AND) and | (OR), with ! for negation and ( ) for grouping.
Comparison operators
Use these between two values – each side is a literal value or a SmartField token, written without surrounding quotes. The single exception is '', which means the empty string (see below).
| Operator | Reads as | Example | True when |
|---|---|---|---|
= | equals | {{httpRequest.statusCode}} = 200 | both sides are equal |
!= | not equal | {{customer.blocked}} != '' | the values differ |
> | greater than | {{order.total}} > 1000 | left is strictly greater |
< | less than | {{stock.qty}} < 5 | left is strictly less |
>= | greater or equal | {{order.total}} >= 1000 | left is greater or equal |
<= | less or equal | {{stock.qty}} <= 5 | left is less or equal |
~ | contains | {{description}} ~ urgent | right value appears anywhere in left |
^= | starts with | {{customer.no}} ^= C0 | left begins with right |
$= | ends with | {{file.name}} $= .pdf | left ends with right |
Numbers vs. text. Comparisons (=, !=, >, <, >=, <=) check both sides numerically when both parse as numbers, otherwise they fall back to text comparison. So {{order.total}} >= 1000 works whether the SmartField resolves to 1000 or 1.000,50. {{customer.name}} = Adatum works because both sides are text.
Don't put quotes around text. Write the literal bare – DE, not 'DE'. AutoFlow compares the operands exactly as written, so the quotes would become part of the value: {{customer.priority}} = 'A' resolves to A = 'A', which is false because A differs from 'A'. Write {{customer.priority}} = A instead.
The empty string. The one place quotes are used is the empty string: two single quotes – '' – mean "empty". {{customer.blocked}} != '' is the idiomatic "is the customer blocked?".
Combining conditions
| Operator | Reads as | Example |
|---|---|---|
& | AND | ({{order.total}} >= 1000) & ({{customer.country}} = DE) |
| | OR | ({{customer.priority}} = A) | ({{order.urgent}} = true) |
! | NOT | !({{customer.blocked}} = '') |
( ) | grouping | ({{a}} = 1 | {{a}} = 2) & ({{b}} != '') |
Wrap every comparison in its own parentheses when you join it with & or | – write (A) & (B), never A & B. The evaluator has no operator precedence of its own: it splits an expression on the first comparison operator it finds, so an unparenthesised A & B is misread (the & ends up inside one operand) and the condition silently evaluates wrong – often always true or always false. Parentheses reduce each comparison to a single true/false first, and only then are & / | applied. ! likewise always sits in front of a parenthesised group: !(…).
A few full examples
{{httpRequest.statusCode}} = 200
Did the request succeed?
({{customer.blocked}} != '') & ({{order.total}} > 0)
The customer is blocked and the order isn't empty.
({{file.name}} $= .pdf) | ({{file.name}} $= .PDF)
Filename ends with .pdf (case-sensitive – cover both spellings, or normalise upstream).
!({{salesHeader.status}} = Released)
Anything except a released sales document.
Tips
- Don't quote text values. Write literals bare –
DE,Released,200. Surrounding quotes become part of the value and the match fails (Adatum≠'Adatum'). The only quoted form the evaluator understands is'', meaning the empty string. - Parenthesise every comparison you combine.
&and|only work on parenthesised comparisons –(A) & (B). See "Combining conditions" above. - Keep it short. If the expression is hard to read, push the work into a Parser step that builds a clean boolean SmartField, and let the Decision/Find Records step reference that field.
- Strings are case-sensitive. Match the casing the data actually has, or normalise both sides through a Parser step first.
SmartFormulas
A SmartFormula is a small math expression you drop inline into any text field by wrapping it in [[ … ]]. AutoFlow evaluates the expression, formats the result, and substitutes the whole [[ … ]] block with the formatted number.
The general shape is:
[[expression]]
[[expression;format]]
The optional ;format clause picks a specific Business Central format string. Leave it off (or write a bare ;) and you get the default rendering – AutoFlow uses <Standard Format,9> under the hood, which is locale-neutral (decimal point, no thousand separators).
Operators
| Operator | Does | Example |
|---|---|---|
+ | add | [[2 + 3;]] → 5 |
- | subtract | [[10 - 4;]] → 6 |
* | multiply | [[{{order.total}} * 0.19;]] |
/ | divide | [[{{order.total}} / {{order.lines}};]] |
% | modulo (remainder) | [[7 % 3;]] → 1 |
^ | power | [[2 ^ 8;]] → 256 |
( ) | grouping | [[(1 + 2) * 3;]] → 9 |
Functions
| Function | Does | Example |
|---|---|---|
max(a, b) | larger of two values | [[max({{order.total}}, 100);]] |
min(a, b) | smaller of two values | [[min({{quote}}, {{cap}});]] |
abs(a) | absolute value | [[abs({{difference}});]] |
round(value, decimals) | round to N decimals (banker's) | [[round({{order.total}} * 1.19, 2);]] |
floor(value, decimals) | round down to N decimals | [[floor({{order.total}}, 0);]] |
ceil(value, decimals) | round up to N decimals | [[ceil({{order.total}}, 0);]] |
round, floor, and ceil take a decimals argument: 2 rounds to two decimals (12.347 → 12.35), 0 rounds to whole numbers, negative values round to tens / hundreds (-2 → nearest hundred).
The format string
The part after the ; is a standard BC format string – the same one you'd pass to Format(value, 0, '<format>') in AL. A few useful shapes:
| Format | Result for 1234.5 |
|---|---|
| (omitted or empty) | 1234.5 |
<Precision,2:2> | 1234.50 |
<Standard Format,0> | 1,234.5 (English) / 1.234,5 (German) |
<Precision,2:2><Standard Format,0> | 1,234.50 (English) / 1.234,50 (German) |
For most cases, leaving the format off ([[…]]) is fine – you get a locale-neutral decimal rendering (decimal point, no grouping). Reach for a format string only when you need precision control or your local number format.
Rendering in your local (regional) format
To show a number the way your BC session displays amounts – with your locale's thousand and decimal separators – add <Standard Format,0>. For example, in a German session:
Amount: [[{{order.total}};<Precision,2:2><Standard Format,0>]] EUR
turns a value of 38401.05 into 38.401,05. The <Standard Format,0> part is what switches to your local separators and grouping; put <Precision,2:2> in front of it to fix the number of decimals. A precision token on its own (<Precision,2:2>) stays locale-neutral.
Examples
The total with VAT is [[{{order.total}} * 1.19;]] EUR.
Plain inline calculation.
Net: [[{{order.total}};<Precision,2:2>]] EUR
Tax: [[round({{order.total}} * 0.19, 2);<Precision,2:2>]] EUR
Two formulas in one block of text, both formatted to two decimals.
Buffer days: [[max({{daysLeft}} - 2, 0);]]
Never go below zero.
Tips
- Don't quote numbers. Formulas only see numbers –
{{order.total}}resolves to the number, not to text. If a SmartField resolves to text that looks like a number, it works; if it resolves to non-numeric text, the formula breaks. - One formula = one number. If you need a calculation that depends on a yes/no decision, use a Decision step or a Parser step to pick the right value first, then drop the SmartField into the formula.
- Use parentheses freely. Multiplication and division bind tighter than addition and subtraction, but parentheses are the easy way to be sure of the intent.
Where they show up
| Step | Field | Type |
|---|---|---|
| Decision | Condition | SmartFilter |
| Find Records | Smart Filter | SmartFilter |
SmartFormulas can appear inline in any text-accepting field on a step configuration – descriptions, URLs, request bodies, parser inputs, error messages, and so on. Wherever a SmartField token ({{ … }}) is allowed, a SmartFormula block ([[ … ; ]]) is allowed too.