Skip to main content
This page is unlisted and can only be accessed directly via URL. It is excluded from the site navigation and search results.

Create backend functions to reuse queries and logic in apps

Backend functions enable you to write complex, multi-step logic with dynamic parameters. Backend functions are reusable within an app, providing the ability to perform the same actions on different pages, with different parameters, and return different data. Backend functions for apps execute code server-side.

In beta, backend functions can be reused within a single app. Organization-wide reuse across multiple apps is coming soon.

Backend functions work similarly to other kinds of code: you can define the run behavior and configure event handlers. However, because backend functions in apps are currently in closed beta, there are certain limitations to be aware of.

Key features

Key features of backend functions for apps include:

  • Chain resource queries with code blocks, conditionals, and error handling in a workflow-like canvas.
  • Support for Python and JavaScript scripting in apps.
  • Accept dynamic, typed input parameters and return structured JSON results.
  • Execute entirely on the backend, sending only final results to the client. This allows you to keep sensitive logic server-side.
  • Support for preloaded libraries.

Limitations

Because backend functions for apps are currently in closed beta, there are certain limitations to be aware of. Future iterations of the feature might address these limitations:

  • Backend functions are currently only available on cloud instances. They are not yet available on self-hosted instances.
  • Backend functions are local to the app where they're created. You can't call a backend function from another app, workflow, or agent.
  • Source Control is not currently supported. Backend functions aren't version controlled alongside your apps.

The following limitations are intentional to ensure secure execution, audibility, and low latency. If they prevent you from leveraging backend functions successfully, please leave a comment on the community forum thread.

  • Custom npm or pip packages are not supported.
  • Running backend functions from embedded expressions or other queries is not supported.

Create a backend function

Use the following steps to create a backend function in an app:

  1. Open the Code tab, and click in the global or page scope section.
  2. Click Function.
  3. Define the parameters that you want to pass into the backend function. For each parameter, you can optionally add a default value, add a description, or mark as required. Parameters allow you to send values from the app to the backend function.
  4. Define the logic that you want your backend function to include. Backend functions can use single-step or multi-step logic. To create multiple steps, click Add steps in canvas. This opens a canvas similar to that of a workflow, which allows you add multiple blocks and define a control flow.
  5. Configure the run behavior or event handlers for your backend function.
  6. Click Save when you are done creating your backend function. If your backend function has a default value, you can click Test to preview the behavior.

The following example includes a backend function that will be used to delete a customer record based on their ID. The parameters include the customer's id and name, and there are two logic blocks: a resource query that deletes the record using a REST API call, and a query that triggers an email notification after the deletion occurs.

Run a backend function

You can configure a backend function to run automatically or when explicitly triggered. To trigger a backend function run, configure an event handler and provide the data that you want to use for each parameter. Reference a backend function's results using functionName.data

The following example shows how you could configure a "Delete User" button event handler to run the backend function created in the previous step.

It is not possible to run a backend function from within embedded expressions or other queries.

Feedback

If you have any feedback on backend functions for apps, please leave a comment on the community forum thread.