Skip to content
Data & Databases

Merge Item Order Preserver via Ordinal Keys with Swap Report

8 nodes 67 5 Manual trigger
Download

Loading workflow…

Workflow Description

A fully local n8n template solving item-order loss after Merge nodes. It emits fictional test data, stamps every item with a sequential ordinal key before branching, splits items via If into two Set-enrichment branches that retain all fields, merges them in append mode, then resorts by ordinal and emits an explicit swap report showing how many positions the merge changed and which item moved where. No credentials or external calls required.

How it works

  1. 1.Run Demo Trigger; Emit Sample Records produces six fictional records including ones with empty emails.
  2. 2.Assign Ordinal Keys adds a sequential ordinal to every item before any branching.
  3. 3.Route by Amount sends items with amount over 100 to the high-value branch, others to the standard branch.
  4. 4.Each Set node adds processingTier and emailStatus with includeOtherFields:true, preserving ordinal and customer fields.
  5. 5.Append Branches combines both branches via append mode with two independent inputs, typically breaking the order.
  6. 6.Resort by Ordinal and Report sorts ascending by ordinal, compares pre/post-merge positions, and emits one swap report.

Use cases

  • Reports that must keep incoming row order after merging multiple processing branches
  • Automatic detection of merge-induced reordering before publishing a workflow
  • Customer record processing split into high-value and standard tiers with guaranteed sequence integrity

Requirements

  • No credentials or external calls — the template is fully local
  • To use real data: connect your real source directly to Assign Ordinal Keys with the same schema: id, customer, email, amount

Setup and testing in n8n

  1. Import the JSON into n8n and open the workflow
  2. Execute Demo Trigger and inspect Resort by Ordinal and Report: sortedCount=6 and sortedRecords matches input order
  3. Verify swapReport states the merge changed 5 positions with item-by-item move details
  4. Edge case: empty the records array in Emit Sample Records and confirm the safe no-items output

Service Value

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

Apps Used

Manual Trigger Code If Set Merge

Details

Trigger Manual trigger
Nodes 8
Apps 5
Views 67
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 (8)

/

Stage 1 Note

Sticky Note

#1

Stage 2 Note

Sticky Note

#2

Stage 3 Note

Sticky Note

#3

Demo Trigger

Manual Trigger

#4

Emit Sample Records

Code

#5

Assign Ordinal Keys

Code

#6

Route by Amount

If

#7

Enrich High-Value Branch

Set

#8

Enrich Standard Branch

Set

#9

Append Branches

Merge

#10

Resort by Ordinal and Report

Code

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