Skip to content
Data & Databases

Two-Path Optional Field Normalizer with Per-Field Provenance

7 nodes 48 3 Manual trigger
Download

Loading workflow…

Workflow Description

A self-contained n8n template that normalizes heterogeneous JSON records where an optional field appears in some records and is missing in others. A Code node emits five fictional records with an original index, an If node splits them into two explicit paths: the present path goes through a Set node that tags the path and stringifies the raw value, while the absent path goes through a safe NoOp. A Merge node in append mode rejoins both paths, and the final Code node applies defaults, builds a per-field status (original, default_applied, missing or invalid), counts defaults and restores the original order.

How it works

  1. 1.Manual Trigger starts the run with one empty item
  2. 2.Code node emits five heterogeneous sample records with _idx
  3. 3.If node checks discount_rate is defined, not null and not empty string
  4. 4.Present path: Set with includeOtherFields adds _discount_path=present and discount_rate_text
  5. 5.Absent path: NoOp passes the record through safely
  6. 6.Merge in append mode with two inputs rejoins both branches
  7. 7.Final Code node applies defaults, builds field_status, trims/uppercases and sorts by index

Use cases

  • Unifying customer records coming from different JSON sources
  • Preparing data before loading into systems that require a fixed schema
  • Data quality auditing to see which fields were defaulted
  • Avoiding silent failures downstream when optional fields are missing

Requirements

  • n8n 2.45.7 or newer
  • No credentials or external calls required
  • Replace the sample node with your real source using the same keys
  • Add _idx if you need original ordering preserved

Setup and testing in n8n

  1. Import the template JSON into n8n
  2. Click Execute Workflow and open Apply Defaults And Field Status
  3. Verify five records ordered from index 0 to 4
  4. Verify C-1004 shows invalid_default_applied while C-1002 and C-1005 show missing_default_applied
  5. Edge case: empty the records array in the sample node and confirm status=empty_input
  6. Edge case: add a record with discount_rate '0.2' and confirm it stays 0.2 with status original

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 7
Apps 6
Views 48
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 (7)

Manual Trigger

Manual Trigger

#1

Load Heterogeneous Sample Records

Code

#2

Optional Field Present?

If

#3

Normalize Present Value

Set

#4

Absent Field Safe Path

No Op

#5

Merge Both Paths

Merge

#6

Apply Defaults And Field Status

Code

#7

Stage Notes

Sticky Note

#8

Setup Notes

Sticky Note

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