Skip to content
Data & Databases

Flatten Variable Key/Value Pairs into Long Label/Value Rows per Deal

9 nodes 51 3 Manual trigger
Download

Loading workflow…

Workflow Description

A manual-trigger workflow that converts a nested CRM deals payload with a variable number of key/value pairs into long rows with four fixed columns: deal_id, dot-path field label, value, and source array. Nested objects are flattened to dot paths; every pair (including deal_id itself) becomes its own row; a Set node normalizes the final columns; empty-valued rows are split by an If node, tagged, and merged back with filled rows, so the total of 14 rows equals the flattened pair count.

How it works

  1. 1.Manual Trigger starts execution with an empty item
  2. 2.A Code node emits a fictional demo payload of two deals with fully different keys
  3. 3.A Code node flattens each deal into one row per key/value pair (deal_id included) with dot-path flattening
  4. 4.A Set node normalizes the four final columns
  5. 5.An If node splits empty-valued rows from filled ones
  6. 6.Two Set nodes tag rows as filled or empty_value
  7. 7.A Merge node in append mode recombines both branches; a NoOp is the final checkpoint

Use cases

  • Normalizing CRM deals with variable keys before reports or spreadsheets
  • Flattening nested JSON payloads into a repeatable fixed-column shape
  • Data quality checks by isolating empty fields

Requirements

  • No credentials needed; fully local execution
  • For real data, replace the demo payload Code node with CRM/HTTP output using schema deals: [...]

Setup and testing in n8n

  1. Import the JSON into n8n and run the Manual Trigger
  2. Verify 14 output rows (7 per deal, including the field_label=deal_id rows) with fixed columns and stage/notes/probability/region tagged empty_value
  3. Try a payload with completely different keys; columns stay fixed and row count equals the flattened pair count
  4. Test an empty payload or a deal with no pairs; the workflow must not fail

Service Value

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

Apps Used

Manual Trigger Code Set If Merge No Op

Details

Trigger Manual trigger
Nodes 9
Apps 6
Views 51
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 (9)

/

Manual Trigger

Manual Trigger

#1

Sample CRM Deals Payload

Code

#2

Flatten Each Deal into Long Rows

Code

#3

Normalize Final Columns

Set

#4

Is Value Filled?

If

#5

Tag Filled Rows

Set

#6

Tag Empty Rows

Set

#7

Append Filled and Empty Rows

Merge

#8

Final Checkpoint

No Op

#9

Docs - Fixed Row Schema

Sticky Note

#10

Docs - Routing and Merge

Sticky Note

#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