Getting started
Rules Engine Widgets
Run Javascript
10 min
overview the run javascript node executes custom javascript code within simplita ai workflows it enables dynamic data transformations, calculations, api interactions, and complex logic operations using javascript in a secure server side environment component classification node type logic node → custom logic runtime node js javascript engine output variable jsresult (configurable) code support es6+ javascript features key characteristics server side execution runs on backend, not browser workflow integration access to previous node results asynchronous supports async/await and promises error capture automatic error reporting json output results must be json serializable no dom browser apis unavailable configuration sections input variables import data from previous nodes assign custom variable names access in code by name code editor javascript syntax highlighting line numbering and error detection es6+ feature support reference input variables directly output configuration specify output variable name (default jsresult) results automatically serialized to json execution settings configurable timeout automatic error handling available capabilities javascript objects string, array, object, number, boolean, date, math, json, regexp es6+ features arrow functions, template literals, destructuring, async/await, promises, classes libraries lodash, date fns, axios, uuid, crypto, querystring unavailable file system, system commands, database direct access basic usage search "javascript" in workflow elements drag node to canvas add input variables (optional) write javascript code configure output variable name execute workflow code examples string processing const text = "hello";const result = text touppercase(); array filtering const nums = \[1, 2, 3, 4, 5];const result = nums filter(n => n > 2); object manipulation const user = { name "john", age 30 };const result = { user, status "active" }; date operations const date = new date();const result = date toisostring(); conditional logic const score = 85;const result = score >= 80 ? "pass" "fail"; output usage full result {{jsresult}} object property {{jsresult fieldname}} array element {{jsresult}} nested value {{jsresult parent child}} error handling common issues syntax errors (missing brackets, semicolons) undefined variables or properties type mismatches (adding string to number) timeout exceeded solutions verify variable names and spelling validate data types before operations handle errors with try catch test incrementally best practices use clear variable names add explanatory comments validate input data handle edge cases keep code focused and simple ensure json serializable output test with sample data javascript vs python feature javascript python best for string/web tasks data calculations async native limited json built in import needed use case formatting, api calls data processing quick start input variables → write code → set output variable → execute result access in next node {{jsresult}} output format json