Lesson 8 / 25
Edit Fields (Set) and Expressions
Create and rename fields with the Edit Fields node and write safe expressions.
Build the exact payload
The Edit Fields (Set) node creates, renames or removes fields so the next system receives exactly the shape it expects. Use it before API calls to build the request body and after them to keep only the fields you need, which also keeps execution data small. Guard against missing values with ?. and ?? in expressions.
Shape the data
Most automation work is cleaning, reshaping and checking data between two systems.
Safe expressions
Without ?., reading a nested field of a missing object throws an error and stops the item. ?? supplies a default.
full_name : {{ $json.first_name }} {{ $json.last_name }}
city : {{ $json.address?.city ?? "Unknown" }}
total_inr : {{ Number($json.total) || 0 }}
is_big : {{ $json.total > 5000 }}Keep only what you need
Dropping unused fields early makes later nodes simpler and avoids sending personal data to services that do not need it.
Quick check: What does `$json.address?.city ?? "Unknown"` do when address is missing?
- Throws an error
- Deletes the item
- Returns "Unknown"
- Returns the address object
Answer
Returns "Unknown" — Optional chaining avoids the error, and the nullish default fills in the fallback value.