Explicit Link Keys Before Merge with Post-Merge Reference Recovery Audit
Loading workflow…
Workflow Description
A fully local template that fixes broken item references after a Merge node. A manual trigger feeds two Code branches that stamp every item with an explicit composite link key built from branch id, source index and a normalized fingerprint of distinguishing fields. Branches are appended by Merge, then a final Code node validates key uniqueness, builds a copy-ready reference expression per item, and emits one report item listing per-branch counts, merged count, duplicate keys, missing indexes and invalid rows. A Set node adds the pattern name while keeping all fields. No credentials, no external calls.
How it works
- 1.Manual Trigger starts both branches.
- 2.Branch A Code emits three rows and adds linkKey = A#index#fingerprint(orderId,amount).
- 3.Branch B Code emits rows at indexes 0, 2, 3 (index 1 intentionally missing, one invalid row) with linkKey = B#index#fingerprint(orderId,status).
- 4.Merge in append mode joins branch A to input 1 and branch B to input 2.
- 5.Final Code counts items per branch, detects duplicate keys, computes index-level gaps, flags invalid rows, outputs enriched items plus one verification report item.
- 6.Set with includeOtherFields:true appends workflowPattern to every item.
Use cases
- Guarantee per-item reference recovery after merging branches
- Detect a lost item by its index instead of only a count delta
- Produce stable reference expressions that survive Merge
- Audit link-key uniqueness before building downstream logic
Requirements
- n8n 2.45.7 or a compatible version
- No credentials and no network access
- Replace both rows arrays with real items of the same schema
- Update keyFields per branch with your real distinguishing fields
Setup and testing in n8n
- Import the workflow JSON and open it.
- Click Execute Workflow and inspect the Stamp Pattern Name output.
- Verify the six linked items each carry a unique linkKey with linkKeyUnique=true.
- Verify the report item shows indexGaps for branch B at index 1 and invalidItems for the empty orderId row.
- Edge cases: duplicate a row in branch A so status becomes failed_duplicate_keys; empty both rows arrays to get the empty_input report.
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 (6)
Manual Trigger
Manual Trigger
Branch A Source And Link Key
Code
Branch B Source And Link Key
Code
Merge Branches
Merge
Verify And Build Reference
Code
Stamp Pattern Name
Set
Note Sources
Sticky Note
Note Merge
Sticky Note
Note Verification
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