Filter actions decide whether a record (an order, a line item, a return, a shipment) continues through DropStream’s processing or gets stopped. There are four:
-
accept— let it continue. -
reject— stop it from continuing. -
default accept— accept anything no other rule decided on. -
default reject— reject anything no other rule decided on.
By default, every record is accepted. You only need filter actions when you want to stop something or set a non-default fallback.
reject
when
order.shipping_address.country is "MX"
then
reject order
end
Rejected records don’t move forward. For an order, that means it doesn’t go to the warehouse. For a line item, that means the item is removed from the order. The order itself continues with whatever items remain.
for order_lines in order
when order_line.custom.is_restricted then
reject order_line
end
end
accept
The default for everything is accept. Writing accept order explicitly is rarely necessary — but it’s useful as the match in a series of when blocks where rejection is the fallback:
for order_lines in order
when order_line.qty_ordered - order_line.qty_fulfilled >= order_line.qty_ordered then
accept order_line
end
end
default reject order_line
Read this as: for each line, if there’s enough inventory, accept it. Anything we didn’t accept, reject by default.
default accept and default reject
A default filter action applies to every record the rule didn’t explicitly decide on. Use it as a fallback at the end of the rule.
rule "Allow only US and Canadian shipments"
when
order.shipping_address.country is "US"
or order.shipping_address.country is "CA"
then
accept order
end
default reject order
end
The when block accepts US and Canadian orders. The default reject at the end catches everything else — Mexico, UK, etc.
A default doesn’t go inside a when — it’s a top-level statement, typically the last line before the closing end.
How the four interact
For a given record, the most specific decision wins:
- An explicit
acceptorrejectalways overrides adefault. - If multiple
whenblocks both fire, the last one wins. So put more-specific rules later. - If no
accept/rejectfires and nodefaultis set, the record is accepted.
What you can filter
-
Orders —
accept order,reject order. Rejecting an order stops it from going to the warehouse. -
Line items —
accept order_line,reject order_line. Rejected items are removed from the order; the order itself continues. -
Other models in their respective hooks — e.g.
reject sales_order_return_itemin a Return Import hook.
Common patterns
Whitelist by country:
when order.shipping_address.country is "US" then accept order end
default reject order
Reject anything restricted:
for order_lines in order
when order_line.custom.is_restricted then reject order_line end
end
Reject by SKU pattern:
for order_lines in order
when order_line.sku starts_with "BANNED-" then reject order_line end
end
Inventory-aware filtering:
for order_lines in order
for inventories in order_line
when
inventory.available >= order_line.qty_ordered
and inventory.warehouse_id is "PRIMARY"
then
accept order_line
end
end
end
default reject order_line
For each line, look at each inventory record. If there’s enough at the primary warehouse, accept. Otherwise, the default reject kicks in.
Tips
- Test with the trace harness. A reject that fires when you didn’t expect — or doesn’t fire when you did — is best diagnosed in the trace, where you can see exactly which conditions evaluated to what.
-
defaultafter, not before. Adefaultdoesn’t apply retroactively — but ordering still matters for readability. - Reject on a line item doesn’t reject the order. A line being rejected shrinks the order; the order itself continues unless explicitly rejected.
Comments
Please sign in to leave a comment.