Skip to content

Procedure: Custom Scripting

TODO: Explain when and why to use scripting (2-3 paragraphs)

TODO: Describe audience:

  • Technical specialists
  • Integrators
  • Advanced Power Users

TODO: When you need scripting:

  • Complex logic without visual builder
  • Complex data transformations
  • Mathematical calculations
  • Regex expressions
  • Advanced looping

TODO: Explain supported language:

  • Language: JavaScript/Node.js
  • Syntax: ES6+
  • Available in: Custom actions

TODO: How to add script:

  1. In flow: ”+ Add action”
  2. Search “Script”
  3. Click “Custom code”
  4. Write code
  5. Test

TODO: Variables available in script (scripting - inline formulas):

  • input: Trigger data
  • previous: Previous step output (previous node data)
  • context: Board information
  • env: Environment variables

Accessing variables:

// TODO: Access example
const nombre = input.nombre;
const valor = previous.resultado;

TODO: Available functions:

  • JSON.parse() / JSON.stringify()
  • Array methods (map, filter, reduce)
  • String methods
  • Date functions
  • Math functions

Example:

// TODO: Transformation example
const numeros = [1, 2, 3];
const suma = numeros.reduce((a, b) => a + b, 0);
return suma;

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 pattern
const resultado = {
exito: true,
datos: procesados
};
return resultado;

TODO: Catch errors:

  • Try/catch
  • Return error object
  • Alert vs continue

Example:

// TODO: Try/catch example
try {
const resultado = realizarOperacion();
return resultado;
} catch(e) {
return {
error: true,
mensaje: e.message
};
}

TODO: What you CANNOT do:

  • File system access
  • HTTP calls (use HTTP action)
  • Infinite loops
  • Persistent global variables

TODO: How to debug:

  1. Use console.log() in script
  2. View logs in right panel
  3. Test flow
  4. View output in execution

Example:

console.log("Value:", input.valor);
console.log("Type:", typeof input.valor);

TODO: Test before using:

  1. Click “Test” in action
  2. Provide input data
  3. View result
  4. Review console logs
  5. Adjust if needed

TODO: Useful scripts:

1. Transform format:

// TODO: Example

2. Validate data:

// TODO: Example

3. Calculate value:

// TODO: Example

4. Process array:

// TODO: Example

TODO: Optimize scripts:

  • Avoid nested loops
  • Use optimized functions
  • Cache if possible
  • Monitor execution time

TODO: Error table:

ErrorCauseSolution
”Cannot read property”Undefined variableVerify spelling
”Timeout”Script takes too longOptimize code
”Syntax error”Invalid codeReview syntax

TODO: Explanations:

  • Script:
  • Context:
  • Return:
  • Console:

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

TODO: What to learn:

  • Complex use cases
  • Scripting patterns
  • Advanced optimization