Two-Path Optional Field Normalizer with Per-Field Provenance
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.Manual Trigger starts the run with one empty item
- 2.Code node emits five heterogeneous sample records with _idx
- 3.If node checks discount_rate is defined, not null and not empty string
- 4.Present path: Set with includeOtherFields adds _discount_path=present and discount_rate_text
- 5.Absent path: NoOp passes the record through safely
- 6.Merge in append mode with two inputs rejoins both branches
- 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
- Import the template JSON into n8n
- Click Execute Workflow and open Apply Defaults And Field Status
- Verify five records ordered from index 0 to 4
- Verify C-1004 shows invalid_default_applied while C-1002 and C-1005 show missing_default_applied
- Edge case: empty the records array in the sample node and confirm status=empty_input
- 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
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 (7)
Manual Trigger
Manual Trigger
Load Heterogeneous Sample Records
Code
Optional Field Present?
If
Normalize Present Value
Set
Absent Field Safe Path
No Op
Merge Both Paths
Merge
Apply Defaults And Field Status
Code
Stage Notes
Sticky Note
Setup Notes
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