Workflow step

Code

Code runs inline JavaScript DSL with mapped workflow inputs. Use it when logic belongs to one workflow step, such as preparing a payload from several earlier outputs.

Choose Add step → Code, map the inputs your logic needs, and edit the code in the step workspace. Test with representative data and inspect the returned value before mapping its fields downstream. Include a test for absent optional data, since live events may differ from the saved sample.

For example, map a workflow field to an Input Data field named email, then normalize it in the handler. Fields written to request.body become the step output.

JS
addHandler("transform", (request) => {
  const email = String(request.body.email ?? "").trim().toLowerCase();
  request.body = { email };
});

For supported syntax and runtime limits, see the FastHook Transform DSL reference.

To add a field to a JSON object, map the whole object to an Input Data field named payload. The spread copies its existing fields into the result.

JS
addHandler("transform", (request) => {
  request.body = { ...request.body.payload, processed: true };
});

To replace a saved JSON Patch, open the step to review its operations. Under App, choose Change, then Code. Recreate the edits in the handler and test with a representative input before publishing.

Replace a saved JS Transformation step

Open the existing step and follow its link to the saved script. Choose Change app → Code and copy the handler into the Code editor. Map each input the handler reads. If it expects the previous step's entire output, map that value as a named input and update how the handler reads it. Review any use of event headers, query parameters, path, method, or resource environment variables. Code builds its request from the configured Input Data and uses an empty resource environment.

Compare test output with a representative run before publishing. To transfer the workflow, export it again after the replacement.