9.2 Writing Custom Code
You understand what the Custom Code Node can do. Now let's actually build one. This section shows you how to add a Custom Code column and write your first script.
Step-by-Step: Adding a Custom Code Column
Step 1: Open Add Column Modal
From your taible:
Look for the "+" button in the column headers
- Usually at the right end of your columns
- Or next to an existing column
Click the "+" button
- Add column modal opens
- Shows available column types
Add Column
Categories:
- All
- Data
- AI & LLM
- Development
- Communication
Column Types:
Step 2: Find Custom Code Column Type
Method 1: Search
Method 2: Browse by Category
- All
- Data
- AI & LLM
- Development ←
- Communication
Step 3: Column Configuration Opens
After clicking "Code":
Configuration panel appears with settings:
Configure Column
Node Configuration
Configuration Fields Explained
Field 1: Column Name
Label: "Column Name"
Purpose: Internal identifier for the column
Rules:
- No spaces (use underscores)
- Lowercase recommended
- Alphanumeric and underscores only
- Must be unique in taible
Examples:
- ✅
lead_score - ✅
custom_validation - ✅
calculate_discount - ❌
Lead Score(spaces not allowed) - ❌
lead-score(hyphens not allowed)
Use in code: Access with the system variable for that column
Field 2: Display Label
Label: "Display Label"
Purpose: Human-readable name shown in column header
Rules:
- Can contain spaces
- Any characters allowed
- Displays in column header
Examples:
- "Lead Score"
- "Custom Validation"
- "Calculate Discount"
User sees this in the taible grid
Field 3: Output Type (Optional)
Label: "Output type"
Purpose: Specifies the data type returned by your code
Default: any (accepts any type)
When to specify:
- Type safety
- Better autocomplete in dependencies
- Documentation
Simple types:
Collection types:
Custom types (if defined in your system):
Leave as any if you're not sure—it will work fine!
Field 4: Code to be executed
Label: "Code to be executed"
The main event: This is where you write your Groovy code
Editor features:
- ✅ Line numbers: Easy reference
- ✅ Syntax highlighting: Color-coded
- ✅ Autocomplete: Access column names (via CTRL + SPACE)
- ✅ Multi-line: Write complex scripts
- ✅ Current line highlight: Know where you are
- ✅ Template badges: See column references as green badges
This is your canvas for custom logic!
Writing Your First Custom Code
Example 1: Simple Calculation
Goal: Calculate order total from quantity and price
How to enter this:
Click in "Code to be executed" editor
Type or paste the code
Set output type:
Double(it's a number)Set column name:
order_totalSet display label: "Order Total"
Click "Save"
Result: New column appears, calculates total for each row
Example 2: String Concatenation
Goal: Combine first name and last name
Configuration:
- Column name:
full_name - Display label: "Full Name"
- Output type:
String
Tip: This is simple enough that you could use a template instead! But it demonstrates the basics.
Example 3: Conditional Logic
Goal: Assign lead tier based on score
Configuration:
- Column name:
lead_tier - Display label: "Lead Tier"
- Output type:
String
Example 4: Return an Object
Goal: Return structured data (multiple fields)
"tier": "Enterprise",
"priority": "High",
"qualified": true,
"category": "Enterprise - High"
}
Configuration:
- Column name:
company_classification - Display label: "Company Classification"
- Output type:
Map<String, Object>
Result: Cell displays as JSON object
Access nested data in other columns using the autocomplete—just start typing the column name and you'll see nested properties available!
Accessing Column Data
How to Reference Columns
In the code editor:
Start typing the column name you want to reference
Autocomplete appears showing matching columns
Select the column from the list
A green badge appears showing the column name
That's it! The system automatically inserts the correct reference when your code runs.
Using Autocomplete
To access column names easily:
In the code editor, press: CTRL + SPACE
Autocomplete popup appears showing available columns
Select column from list
Green badge appears showing the column reference
Tip: You can also just start typing a column name and the autocomplete will filter to matching columns!
Safe Navigation (Avoiding Null Errors)
Problem: Column might be empty or null
Bad code (will crash if empty):
def email = [Email Column]
def domain = email.split('@')[1] // CRASH if email is null!Good code (safe navigation):
def email = [Email Column]
def domain = email?.split('@')?.getAt(1) // Returns null if email is null
// Or with default value
def emailValue = [Email Column] ?: 'no-email@example.com'def domain = email.split('@')[1]
// CRASH if email is null!
def domain = email?.split('@')?.getAt(1)
// Returns null if email is null
Safe navigation operator: ?.
- If left side is null, entire expression returns null
- No crash!
Elvis operator: ?:
- If left side is null, use right side (default value)
Accessing Nested Data
When column contains object:
Accessing Array Data
When column contains list:
Available Built-in Variables
objectMapper (JSON Operations)
Purpose: Parse and create JSON
Column References (Data)
Purpose: Access all column data in current row
Usage: Use autocomplete (CTRL + SPACE) to insert column references
Always available in your code
executeColumn (Advanced)
Purpose: Execute another column programmatically
When to use:
- Conditional column execution
- Dynamic workflows
- Complex dependencies
Caution: Can create circular dependencies—be careful!
Testing Your Custom Code
Step 1: Save Configuration
Click "Save" button at bottom of configuration panel
Column is created in your taible
Configuration closes
Step 2: Add Test Row
To test your code:
Add a new row at the bottom of taible
- Click "Add Row" or use row menu
Fill in dependency columns
- Enter data for columns your code reads
- Example: If code reads quantity and price, enter values
Custom code column executes automatically
- State: Queued → Running → Completed
- Or Error if there's a problem
Step 3: Check Result
If successful (Completed, green badge):
- Cell shows your returned value
- Click cell to see full data
If failed (Error, red badge with zap icon):
- Click cell to see error
- Error sidebar shows detailed information
• Click cell to see full data
• Shows error message and stack trace
Step 4: Fix Errors
Common errors:
| Error | Cause | Fix |
|---|---|---|
| Cannot get property 'field' on null | Accessed null value | Use safe navigation ?. |
| No such property: columnName | Typo in column name | Check spelling in autocomplete |
| Cannot cast X to Y | Type mismatch | Check data types, use conversions |
How to fix:
Click column header → settings icon
Edit code in configuration
Save changes
Select failed cells → Right-click → "Recalculate cells"
Cells re-execute with updated code
Step 5: Test with Multiple Rows
Once working with one row:
Add more test rows with various data
- Test edge cases
- Test empty values
- Test boundary conditions
Verify all execute successfully
Check results make sense
If all good: Your custom code is ready! ✓
Code Editor Tips
Tip 1: Use Comments
Document your code:
// Calculate lead score based on company size and industry
def companySize = [Company Size]
// Award points for company size
def score = 0
if (companySize > 1000) {
score += 30 // Large company
} else if (companySize > 100) {
score += 20 // Mid-size company
}
return scoreWhy: Makes code maintainable
Tip 2: Format for Readability
Bad (hard to read):
def score=0
if([Company Size]>1000){score+=30}else if([Company Size]>100){score+=20}
return scoreGood (easy to read):
def score = 0
def companySize = [Company Size]
if (companySize > 1000) {
score += 30
} else if (companySize > 100) {
score += 20
}
return scoreTip 3: Use Variables
Instead of repeating:
if ([Company Size] > 1000) {
// ... later ...
def size = [Company Size]
}Extract to variable:
def companySize = [Company Size]
if (companySize > 1000) {
// Use companySize
}Benefits: Shorter, clearer, less error-prone
Tip 4: Return Early
Complex nested conditions (hard to follow):
def score = 0
if ([Email]) {
if ([Company Size]) {
if ([Industry]) {
// Calculate score
score = complexCalculation()
}
}
}
return scoreReturn early (easier to understand):
// Validate required fields
def email = [Email]
if (!email) return 0
def companySize = [Company Size]
if (!companySize) return 0
def industry = [Industry]
if (!industry) return 0
// All required fields present, calculate score
return complexCalculation()Tip 5: Test Incrementally
Don't write all at once:
- Start simple:
return "Hello" - Add data access:
return [Email] - Add logic piece by piece
- Test after each addition
If it breaks: You know which piece caused it
Modifying Existing Custom Code
To Edit Custom Code Column
Click column header (column you want to edit)
Click settings icon (⚙️) or three-dot menu (⋮)
Select "Edit Column"
Configuration panel opens with current code
Modify code in editor
Click "Save"
Existing cells keep old values (won't auto-recalculate)
To update cells with new code:
- Select cells
- Right-click → "Recalculate cells"
- Cells re-execute with new code
Version Control Tip
Before major changes:
Duplicate the column (create backup)
- Same code, different name
Test changes in new column
If works: Delete old column
If breaks: Revert to backup
Prevents data loss during experimentation
Common Patterns
Pattern 1: Data Validation
Pattern 2: Fallback Values
Pattern 3: Scoring/Classification
Pattern 4: Data Transformation
Summary: Writing Custom Code
You now know how to write custom code:
✅ Add Custom Code column:
- Click "+" → Search "code" → Configure
✅ Configuration fields:
- Column name (internal identifier)
- Display label (shown in header)
- Output type (optional, for type safety)
- Code editor (where magic happens)
✅ Write code:
- Use autocomplete to insert column references
- Use objectMapper for JSON
- Use executeColumn for dynamic execution
- Return value (simple or complex)
✅ Test code:
- Add test row
- Check result
- Fix errors
- Test edge cases
✅ Code editor tips:
- Use comments
- Format for readability
- Use variables
- Return early
- Test incrementally
✅ Common patterns:
- Data validation
- Fallback values
- Scoring/classification
- Data transformation
Next Steps
Now that you can write custom code, Section 9.3 will show you:
- Real-world custom code examples
- Lead scoring algorithms
- Complex data transformations
- API integration patterns
- Advanced techniques
Let's see custom code in action! 🚀