Procedure: Custom Scripting
Introduction
Section titled “Introduction”TODO: Explain when and why to use scripting (2-3 paragraphs)
Who is this section for
Section titled “Who is this section for”TODO: Describe audience:
- Technical specialists
- Integrators
- Advanced Power Users
Use Cases
Section titled “Use Cases”TODO: When you need scripting:
- Complex logic without visual builder
- Complex data transformations
- Mathematical calculations
- Regex expressions
- Advanced looping
Language and Syntax
Section titled “Language and Syntax”TODO: Explain supported language:
- Language: JavaScript/Node.js
- Syntax: ES6+
- Available in: Custom actions
Accessing Script
Section titled “Accessing Script”TODO: How to add script:
- In flow: ”+ Add action”
- Search “Script”
- Click “Custom code”
- Write code
- Test
Context and Variables
Section titled “Context and Variables”TODO: Variables available in script (scripting - inline formulas):
input: Trigger dataprevious: Previous step output (previous node data)context: Board informationenv: Environment variables
Accessing variables:
// TODO: Access exampleconst nombre = input.nombre;const valor = previous.resultado;Useful Functions
Section titled “Useful Functions”TODO: Available functions:
JSON.parse()/JSON.stringify()- Array methods (map, filter, reduce)
- String methods
- Date functions
- Math functions
Example:
// TODO: Transformation exampleconst numeros = [1, 2, 3];const suma = numeros.reduce((a, b) => a + b, 0);return suma;Return Value
Section titled “Return Value”TODO: What to return:
- Script must return value with
return - Can be string, number, object, array
- That value is passed to next step
Pattern:
// TODO: Typical patternconst resultado = { exito: true, datos: procesados};return resultado;Error Handling
Section titled “Error Handling”TODO: Catch errors:
- Try/catch
- Return error object
- Alert vs continue
Example:
// TODO: Try/catch exampletry { const resultado = realizarOperacion(); return resultado;} catch(e) { return { error: true, mensaje: e.message };}Limitations
Section titled “Limitations”TODO: What you CANNOT do:
- File system access
- HTTP calls (use HTTP action)
- Infinite loops
- Persistent global variables
Debugging
Section titled “Debugging”TODO: How to debug:
- Use
console.log()in script - View logs in right panel
- Test flow
- View output in execution
Example:
console.log("Value:", input.valor);console.log("Type:", typeof input.valor);Testing Scripts
Section titled “Testing Scripts”TODO: Test before using:
- Click “Test” in action
- Provide input data
- View result
- Review console logs
- Adjust if needed
Common Examples
Section titled “Common Examples”TODO: Useful scripts:
1. Transform format:
// TODO: Example2. Validate data:
// TODO: Example3. Calculate value:
// TODO: Example4. Process array:
// TODO: ExamplePerformance
Section titled “Performance”TODO: Optimize scripts:
- Avoid nested loops
- Use optimized functions
- Cache if possible
- Monitor execution time
Common Errors
Section titled “Common Errors”TODO: Error table:
| Error | Cause | Solution |
|---|---|---|
| ”Cannot read property” | Undefined variable | Verify spelling |
| ”Timeout” | Script takes too long | Optimize code |
| ”Syntax error” | Invalid code | Review syntax |
Key Terms
Section titled “Key Terms”TODO: Explanations:
- Script:
- Context:
- Return:
- Console:
Mini FAQ
Section titled “Mini FAQ”Q: Can I call APIs from script?
A: TODO
Q: Is there a time limit?
A: TODO
Q: How do I access secrets?
A: TODO
Next Steps
Section titled “Next Steps”TODO: What to learn:
- Complex use cases
- Scripting patterns
- Advanced optimization