Functions

Write small JavaScript functions that read and change your workspace data, then run them by hand, from flows, queues, forms or a public web address.

Functions are small pieces of JavaScript that you keep in your workspace. Use one when the ready-made blocks are not enough: a custom calculation, a lookup across record types, or a nightly clean-up. A function runs in a sealed sandbox and reaches your data only through permissions.

Functions list beside the function editor

What you can do

  • Write and test a function in the editor, and run it with sample input. Write and run a function
  • Publish when ready — save changes as a draft, test them, publish, and roll back to an earlier version. Drafts and versions
  • Run it on a schedule — every hour, day, weekday or week. Schedules
  • Give a function a public web address so another system can call it. Expose a function over HTTP
  • Run it from Relay — turn a function into a /command anyone can type in a conversation. Webhooks and slash commands
  • Run it automatically from a flow (the Run function block), from a work queue stage, or as a form target.
  • Save test inputs and tell uptime monitors about failures. Write and run a function
  • See what happened — every run with logs, input and output, and replay it. Run history
  • Use built-in helpers — dates and time zones, CSV, and GSTIN, PAN, IFSC and PIN code checks, with nothing to install. Functions SDK
  • Keep keys out of the code — workspace secrets read as axis.env.NAME. Secrets
  • Know the limits and the permission rules. Limits and permissions

Writing against the axis toolkit (records, analytics and so on) is a developer topic. See Developers.

Before you start

  • Who can use it: the Custom code app on the Roles page. Can view lets someone read the code. Can run adds running a function. Full control writes and changes functions. This is a trusted job, because other parts of the workspace can run your code. See Limits and permissions.
  • Functions can be switched off for the whole workspace in Settings → Apps. It must be on.
  • Without view permission you see "No access to Functions".

Where to find it

Launcher › Automation › Functions. There are no sub-sections; Secrets sits in the header. The left side lists your functions. Each shows its name, its description, a Draft badge if it has unpublished changes, an HTTP badge if it has a public address, or an Off badge if it is disabled.

Under each function a line shows how it has run over the last 7 days: how many runs, how many failed (errors and timeouts) with the failure rate, and when it last ran — or No runs in 7 days. The line turns red when any run failed. Open the function's Run history to see each run.

The functions list: one function with 35 runs, one in red with 12 failed (7%), and one with no runs in 7 days

Key ideas

Term What it means
Function A named piece of JavaScript with a handler(input) entry point.
Input The data passed in. You provide it when running by hand. Flows, queues and web requests provide their own.
Result The value your function returns.
Timeout How long a run may take. Default 5000 ms.
Enabled An off function cannot run.
Draft Saved code that is not live yet. Only the Run panel runs it.
Version Code that was published. The Live version is what runs everywhere.
Expose over HTTP Gives the function a public address.

In this section

  • Drafts, publishing and versions — Save changes to a function as a draft, test them, publish when ready, and roll back to any earlier version.
  • Expose a function over HTTP — Give a function a public web address so a website or another system can call it, and understand what it can access.
  • Limits and permissions — Time, memory and size limits for functions, and whose permissions a function runs with in each situation.
  • Run history — See every run of a function — who or what started it, how long it took, its logs, input and output — and run it again with the same input.
  • Run a function on a schedule — Run a function every hour, every day, on weekdays or weekly from its own page, and pause or change each schedule.
  • Secrets — Keep API keys and passwords out of your function code. Save them once as workspace secrets and read them as axis.env.NAME.
  • Write and run a function — Create a JavaScript function, set its timeout, save it and try it with sample input.