Skip to content
Data & Databases

Fold Source Fields Before Merge: Self-Contained Items Without pairedItem Expressions

13 nodes 39 5 Manual trigger
Download

Loading workflow…

Workflow Description

A fully local n8n template. A manual trigger feeds two branches whose Code nodes emit fictional order and payment items. Folding Code nodes copy every field later stages need into the item itself using _a_ and _b_ prefixes, normalise strings and numbers, and compute _fold_missing plus _fold_complete. Set nodes pin _fold_version while keeping other fields. A Merge in append mode joins the branches, an IF routes complete items to a self-check node and incomplete ones to a NoOp, and a second Merge rejoins both routes into one final Code node that flattens each item and labels it complete or quarantined. No credentials, no external calls, no upstream references after the merge.

How it works

  1. 1.Manual trigger emits an empty item into both branch paths
  2. 2.Two Code nodes generate demo items shaped {order, payer}, one with an invalid payer value
  3. 3.Fold nodes copy order.id, amount, currency, payer.name, payer.method into _a_* and _b_* with type normalisation
  4. 4.Each fold node computes _fold_missing, _fold_complete and the _src branch tag
  5. 5.Set nodes add _fold_version with includeOtherFields enabled
  6. 6.Merge in append mode combines both branches into one stream
  7. 7.IF checks _fold_complete with strict type validation: true to the self check, false to the NoOp quarantine
  8. 8.A second Merge rejoins both routes and the final Code node flattens fields, emitting status and missing_fields per item

Use cases

  • Stabilising flows where $('NodeName').item broke after a merge node
  • Unifying order and payment records from two different sources
  • Flagging records with missing fields separately from valid ones
  • Auditing merged data quality before export

Requirements

  • n8n 2.46.4 or a build with equivalent merge behaviour
  • A decided list of fields needed later before editing the fold nodes
  • Replace the two sample Code nodes with real sources using the same {order, payer} schema
  • Never use $('NodeName').item after the merge node

Setup and testing in n8n

  1. Import the JSON and click Execute Workflow
  2. Confirm Build Final Records outputs four records: three complete and one quarantined
  3. Confirm ORD-1003 has status=quarantined with missing_fields containing _b_payerName and _b_payerMethod
  4. Swap the branch wiring between merge inputs 0 and 1 and confirm the same record set
  5. Set one sample array to empty and confirm the run finishes without error

Service Value

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

Apps Used

Manual Trigger Code Set Merge If No Op

Details

Trigger Manual trigger
Nodes 13
Apps 6
Views 39
Downloads 5

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

/

Manual Trigger

Manual Trigger

#1

Sample Branch A Orders

Code

#2

Fold Source Fields Branch A

Code

#3

Pin Folded Fields A

Set

#4

Sample Branch B Payments

Code

#5

Fold Source Fields Branch B

Code

#6

Pin Folded Fields B

Set

#7

Merge Branches Append

Merge

#8

If Folded Fields Complete

If

#9

Self Check Folded Items

Code

#10

Quarantine Incomplete Items

No Op

#11

Merge Verified And Quarantined

Merge

#12

Build Final Records

Code

#13

Note Branch Setup

Sticky Note

#14

Note Architecture Rule

Sticky Note

#15

Note Routing And Output

Sticky Note

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