Skip to content
Data & Databases

Merge Branch Completion Receipt Generator with Empty Branch Detection

10 nodes 69 3 Manual trigger
Download

Loading workflow…

Workflow Description

A self-contained template that splits JSON records with an IF node, tags each item with its branch name in two Code nodes that return an empty array for empty branches, then combines both via an append-mode Merge that never stalls. A final Code node emits a single receipt documenting per-branch counts and the empty branch list, and an IF routes receipts with an empty branch to a review NoOp while complete receipts flow on the other path. Fully local, no external calls.

How it works

  1. 1.Run the Manual Trigger; the sample Code node emits fictional records (normal and invalid)
  2. 2.The IF routes records: status='ok' to the true branch, others to the false branch
  3. 3.Each branch Code node stamps items with source_branch and handles empty input by returning []
  4. 4.The append-mode Merge combines both branch outputs
  5. 5.A final Code node builds one receipt with inputCounts, emptyBranches, emptyBranchesCount and totalItemsMerged
  6. 6.The final IF checks emptyBranchesCount: zero routes to the complete path, otherwise to the review NoOp

Use cases

  • Diagnosing Merge nodes stalling after IF when one branch is always empty
  • Documenting per-branch item counts for every execution
  • Isolating invalid records into a side branch with a receipt showing how many arrived

Requirements

  • An n8n version supporting manualTrigger, code, if, merge, noOp and stickyNote
  • No credentials or external connections required

Setup and testing in n8n

  1. Import the JSON into n8n and execute the workflow
  2. Verify the default receipt (SCENARIO='both') shows branch_true=2, branch_false=1, empty emptyBranches on the complete path
  3. Set SCENARIO='emptyFalse' and re-run: a receipt with emptyBranches=['branch_false'] routes to the review path without stalling
  4. For real data, replace the sample node with your source; items must carry a string status field

Service Value

Ready-made workflow template for automation delivery and service execution.

Apps Used

Manual Trigger Code If Merge No Op

Details

Trigger Manual trigger
Nodes 10
Apps 5
Views 69
Downloads 3

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 (10)

/

Manual Trigger

Manual Trigger

#1

Sample Data (Fictional Test Records)

Code

#2

Branch Split (status = ok)

If

#3

Tag True Branch

Code

#4

Tag False Branch

Code

#5

Merge Branches (Append)

Merge

#6

Build Completion Receipt

Code

#7

Empty Branch Check

If

#8

Complete Flow (No Empty Branch)

No Op

#9

Empty Branch Detected - Review

No Op

#10

Stage 1 - Input & Split

Sticky Note

#11

Stage 2 - Tagging & Merge

Sticky Note

#12

Stage 3 - Receipt & Routing

Sticky Note

#13
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