Sequential Merge Refactor with Count and Key Equivalence Receipt
Loading workflow…
Workflow Description
A self-contained template that removes waiting-Merge deadlocks. Manual Trigger feeds a Code node that emits six fictional records (valid, missing id, non-numeric amount). One Code node then applies every branch rule as a sequential function over the same batch, tagging each item with its branch plus expected and produced totals. An If node strictly compares those counts; the success path passes through a Set node that adds a verification tag while keeping all fields, the fallback path through NoOp, and an append Merge joins both without waiting. A final Code node returns exactly one equivalence receipt.
How it works
- 1.Manual Trigger starts the run with one empty item
- 2.Sample Batch Code node emits six demo records shaped {id,type,amount}
- 3.Sequential Branch Processor validates id, type and numeric amount and routes items to invoices/credits/other/rejected sequentially
- 4.Each produced item carries expected_total, produced_total and input_index
- 5.If node compares produced_total to expected_total with strict number validation
- 6.True path goes through Set adding equivalence_path with includeOtherFields:true
- 7.False path goes through NoOp into Merge input 2 (append mode, no waiting)
- 8.Build Equivalence Receipt returns one item with input/output counts, branch counts, sorted key list and the EQUIVALENT verdict
Use cases
- Replace a two-branch + waiting Merge layout that can deadlock when a branch empties
- Separate valid from rejected records while proving no item was lost
- Audit invoice vs credit classification before handing data to another system
- Produce an internal review receipt with per-branch counts and amount totals
Requirements
- n8n 2.45.7 or newer
- No credentials and no external calls needed
- For real data, replace the Sample Batch node with your own source using the same {id,type,amount} schema
Setup and testing in n8n
- Import the JSON into n8n and run Execute Workflow
- Confirm the final output is one item with equivalence = EQUIVALENT and output_item_count = 6
- Empty-branch test: delete all credit records from Sample Batch and rerun; execution completes and branch_counts has no credits key
- Invalid-input test: strip all ids; every item lands in the rejected branch and total_amount is 0
- Empty test: make Sample Batch return an empty array; a diagnostic item with branch 'empty' is emitted without hanging
Service Value
Ready-made workflow template for automation delivery and service execution.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (8)
Manual Trigger
Manual Trigger
Sample Batch
Code
Sequential Branch Processor
Code
If Count Matches Expected
If
Tag Verified Path
Set
Fallback Path NoOp
No Op
Merge Append Paths
Merge
Build Equivalence Receipt
Code
Note Pattern
Sticky Note
Note Refactor
Sticky Note
Note Verify
Sticky Note
Note Receipt
Sticky Note
Fresh workflows, straight to your inbox
Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.
- New workflows
- Clear overviews
- Setup guides