The Return Import hook fires when a return is imported into DropStream — typically from a returns management system or directly from the warehouse after a customer return is received. The available record is the sales_order_return and its sales_order_return_items collection.
Returns rules tend to focus on categorization, routing to the right disposition warehouse, and flagging exceptions for human review.
Categorize returns by reason
rule "Categorize returns by reason"
set $category to "standard"
when
sales_order_return.custom.return_reason contains "damaged"
or sales_order_return.custom.return_reason contains "broken"
then
set $category to "damaged"
end
when
sales_order_return.custom.return_reason contains "wrong"
or sales_order_return.custom.return_reason contains "incorrect"
then
set $category to "wrong-item"
end
when
sales_order_return.custom.return_reason contains "size"
or sales_order_return.custom.return_reason contains "fit"
then
set $category to "size-fit"
end
set sales_order_return.custom.category to $category
end
The category drives routing and disposition decisions. Adjust the patterns to match the reason codes your system actually uses.
Route damaged returns to disposal
Build this in the visual editor. Warehouses come from a named dropdown. The facility names (after
/) are platform-specific; the values shown below assume your warehouse platform supports facility codes named “Damaged Goods” and “Restocking”.
rule "Route damaged returns"
when
sales_order_return.custom.category is "damaged"
then
route sales_order_return to warehouse 1 / "Damaged Goods"
end
when
sales_order_return.custom.category is "standard"
or sales_order_return.custom.category is "size-fit"
then
route sales_order_return to warehouse 1 / "Restocking"
end
end
Damaged items go to a disposition area; restockable items go back into inventory.
Flag high-value returns for review
rule "Flag high-value returns"
accumulate sales_order_return_items in sales_order_return
total: sum sales_order_return_item.custom.refund_amount
end
when total > 500.0 then
set sales_order_return.custom.tag to "high-value-review"
set sales_order_return.notes to "Review required: $" & total as text & " refund"
end
end
High-value returns get a tag that downstream notification rules or dashboards can pick up.
Fail returns with missing data
rule "Fail returns without RMA"
when
sales_order_return.custom.rma_number is blank
then
fail sales_order_return with "Return " & sales_order_return.id & " has no RMA number"
end
when
sales_order_return.custom.original_order_id is blank
then
fail sales_order_return with "Return " & sales_order_return.id & " has no original order reference"
end
end
A return that can’t be traced back to an order is a problem. Failing it surfaces the issue for a human to fix the upstream data.
Tag fraud-likely returns
rule "Flag potentially fraudulent returns"
when
sales_order_return.custom.return_reason is blank
or sales_order_return.custom.condition is "unknown"
then
set sales_order_return.custom.tag to "review-fraud"
end
when
sales_order_return.custom.days_since_purchase > 90
then
set sales_order_return.custom.tag to "review-old"
end
end
Returns with missing reason codes, unknown condition, or far-out-of-policy timing get tagged for review. Tagging is gentler than failing — the return continues, but the tag flags it for human review downstream.
Reject restocking on certain SKUs
rule "Don't restock hygiene items"
for sales_order_return_items in sales_order_return
when
sales_order_return_item.sku starts_with "HYGIENE-"
or sales_order_return_item.sku starts_with "INTIMATE-"
then
reject sales_order_return_item
# Item won't be added back to inventory
end
end
end
For categories that legally or hygienically can’t be restocked, reject the line item so it doesn’t go back into available stock.
Tips
- The return is the primary record. Unlike Shipment Notification or Invoice Export, the Return Import hook doesn’t expose a parent order — only the return itself. If you need the original order’s data on the return, copy it onto a custom field at order time.
- Reason codes vary by source. Different returns systems use different conventions. Test patterns against real returns from your specific system rather than assuming.
-
Returns rules often pair with notifications. A
tagset in a return rule is most useful when an alert or dashboard reacts to it — DropStream’s alerting system can watch for tags and notify staff.
Comments
Please sign in to leave a comment.