Available for Plus plan and above
Basic Concepts
Teable Script functionality allows you to automate data processing through JavaScript code, implementing complex business logic and data operations.Execution Environment
- Language: JavaScript (ES6+)
- Environment: Secure sandbox environment
- Module System: CommonJS (
require()
) - Support: Top-level await, modern JavaScript features
Getting Input Data
Scripts get output from previous workflow steps through theinput
object. Each previous step’s output uses its actionId as the key:
Setting Output Results (Recommended Method)
Usingoutput.set()
is the best approach because it preserves the complete format of objects:
Dependency Management
If using external npm packages, they must be declared in dependency configuration:HTTP Requests
Use the built-infetch()
function:
Debugging Tips
1. View Input Data Structure
2. Error Handling
Quick Start Steps
- Debug input first - Use
console.log(JSON.stringify(input, null, 2))
to view data structure - Extract needed data - Get field values through
input[actionId].record.fields[fieldId]
- Process data - Use JavaScript for calculations, transformations, filtering, and other operations
- Set output - Use
output.set(key, value)
to set results - Test and verify - Run script to check if output meets expectations
Practical Application Examples
Basic Data Processing
API Call Example
Teable API Operations
Important Notes
Authentication and Security
- Use built-in
process.env.AUTOMATION_TOKEN
- Avoid hardcoding sensitive information in scripts
- Ensure scripts only access necessary tables and fields
Data Processing
- Recommend enabling
typecast: true
for automatic type conversion - Validate input data integrity and format before processing
- Use meaningful field names
Performance Optimization
- Prefer batch operations over individual loop operations
- Use pagination for large datasets
- Only retrieve required fields
Error Handling
- All API calls must be wrapped with try/catch
- Record detailed error information for debugging
- Implement graceful degradation, partial failures should not affect overall flow