Skip to content
Data & Databases

Sequential Merge Refactor with Count and Key Equivalence Receipt

8 nodes 54 6 Manual trigger
Download

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. 1.Manual Trigger starts the run with one empty item
  2. 2.Sample Batch Code node emits six demo records shaped {id,type,amount}
  3. 3.Sequential Branch Processor validates id, type and numeric amount and routes items to invoices/credits/other/rejected sequentially
  4. 4.Each produced item carries expected_total, produced_total and input_index
  5. 5.If node compares produced_total to expected_total with strict number validation
  6. 6.True path goes through Set adding equivalence_path with includeOtherFields:true
  7. 7.False path goes through NoOp into Merge input 2 (append mode, no waiting)
  8. 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

  1. Import the JSON into n8n and run Execute Workflow
  2. Confirm the final output is one item with equivalence = EQUIVALENT and output_item_count = 6
  3. Empty-branch test: delete all credit records from Sample Batch and rerun; execution completes and branch_counts has no credits key
  4. Invalid-input test: strip all ids; every item lands in the rejected branch and total_amount is 0
  5. 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

Manual Trigger Code If Set No Op Merge

Details

Trigger Manual trigger
Nodes 8
Apps 6
Views 54
Downloads 6

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (8)

/

Manual Trigger

Manual Trigger

#1

Sample Batch

Code

#2

Sequential Branch Processor

Code

#3

If Count Matches Expected

If

#4

Tag Verified Path

Set

#5

Fallback Path NoOp

No Op

#6

Merge Append Paths

Merge

#7

Build Equivalence Receipt

Code

#8

Note Pattern

Sticky Note

#9

Note Refactor

Sticky Note

#10

Note Verify

Sticky Note

#11

Note Receipt

Sticky Note

#12
Stay in the loop

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

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime