Level Up Your n8n Workflows: How to Use the Set Node (Edit Fields)

Data is rarely perfect when it first enters your workflow. It might have extra fields you don’t need, inconsistent formatting, or missing values. That’s where the Edit Fields (or Set) Node comes in.

In this tutorial breakdown from GenAI Unplugged, we explore how to use this essential node to clean, modify, and enrich your data for smarter automation.


What Can the Edit Fields Node Do?

The Edit Fields node is your primary tool for data transformation in n8n. Its main functions include:

  • Cleaning Data: Removing unwanted fields to keep your workflow efficient [00:20].
  • Standardization: Converting text to uppercase or lowercase for consistency [00:47].
  • Consistency: Replacing null or “NaN” values with zeros or empty strings [01:05].
  • Enrichment: Adding new calculated fields based on existing data [01:31].

Use Case 1: Creating a “Full Name” Field

Often, data comes with “First Name” and “Last Name” in separate columns. If you only need a single “Full Name” field for an email or a Slack message, you can combine them easily.

  1. Add the Field: Create a new field called full_name.
  2. Use Expressions: In the value box, drag in the firstName property, add a space, and then drag in the lastName property [04:42].
  3. Clean Up: To keep your data tidy, you can use the “Exclude” setting to remove the original firstName and lastName fields once they’ve been merged into the new full_name field [06:03].

Use Case 2: Calculating Order Priority (Logic & Dates)

A more advanced use for the Set node is calculating values on the fly. For example, you might want to tag an order as “High Priority” only if it has been sitting in “Processing” for more than 45 days.

Using the Expression Editor, you can write a simple JavaScript ternary operator (an if-else statement) [09:13]:

  • The Logic: (Days since Order Date > 45) ? "High" : "Standard"
  • How it works: n8n takes the current date ($now), subtracts the orderDate, and checks if the result is greater than 45 [11:04].

This allows your workflow to dynamically assign a priority level to every item, which can then be used by a Switch node to send alerts only for those high-priority orders [07:29].


Key Settings to Remember

  • Manual Mapping vs. JSON Mode: Manual mapping is great for beginners, while JSON mode allows developers to construct entire data structures from scratch [02:16].
  • Include Other Input Fields: By default, the Set node might remove fields you didn’t explicitly mention. Toggle this on to ensure your new fields are added to your existing data rather than replacing it [05:06].

Conclusion

The Edit Fields node is the “Swiss Army Knife” of n8n. Whether you’re doing simple text cleanup or complex date calculations, mastering this node is the key to building professional, robust automations.

Watch the full video tutorial here: How to Use Set Node in n8n

Leave a Comment

Your email address will not be published. Required fields are marked *