JS Scripting
Adding a JavaScript code block step to your automations
Use the JS Scripting action when you need to transform data inside an automation.
Common uses include:
- Comparing values from multiple datasources
- Aggregating rows
- Reshaping output before the next step
Add the step
- Add a trigger to your automation
- Add the
JS Scriptingstep - Open the step details and add any bindings you need
Make sure the script returns a value.
Use bindings
Bindings can be read directly in your script.
Example:
const rows = $("steps.Query rows.rows")
const today = new Date()
const todayMonth = today.getMonth()
const todayDate = today.getDate()
const birthdays = []
rows.forEach((row) => {
const dob = new Date(row.date_of_birth)
if (dob.getDate() === todayDate && dob.getMonth() === todayMonth) {
const age = today.getFullYear() - dob.getFullYear()
birthdays.push({
firstName: row.first_name,
age: age
})
}
})
return birthdaysGood practice
Keep scripts focused on data shaping.
Use a table, form, or app screen for logic that belongs elsewhere.
Related guides
Updated 4 months ago
Did this page help you?