Custom Functions
What are custom functions?
Custom functions are pieces of reusable logic that you can insert into other function stacks. This is most useful when you have a set of steps that remain the same, but need to be executed in multiple places. Placing those steps inside of a custom function allows you to quickly use those steps in other function stacks, while only needing to maintain them in one place.
Using Custom Functions
From the left-side navigation, click Library to access the Library section, and choose Functions from the submenu that appears.
To create a custom function, click + Add Function
Building a custom function is just like building an API. Refer to that documentation for specific instructions on building the function stack.
Publish your changes
You can Publish the custom function to ensure that every place it is called uses the same version.
Insert the custom function any place you need to use it.
In the functions panel, you'll see an option labeled Custom Functions, shown below. Just click it to see a list of your custom functions and add them to other function stacks.

When you make changes to the custom function, the changes populate across everywhere it is used.
Async Execution
Once you've built your custom function and added it to another function stack, you have the option of running the function asynchronously. This just means that the functions will be queued for execution, and the rest of your function stack will continue to execute right away.
Asynchronous functions will utilize your background task resources (unless you are on a Custom or Enterprise plan), so it's important to manage expectations when it comes to execution speed. It would be most appropriate to use asynchronous functions when you need to trigger an operation as part of a larger function stack, but do not need to reference the output in the same stack.
Parallel execution of your async functions (running more than one async function at a time) is handled by workers, and the number of workers scales with each Xano plan. Async functions are placed into a queue and they get processed by available workers β the more workers you have available, the more parallel executions can run.
Enabling Async Execution
Right-click on the custom function in your function stack, and choose Async Settings.
In the panel that opens, choose your desired execution type.
Synchronous is standard execution. Your function stack will allow the custom function to finish executing before continuing.
Async and Async (dedicated) allow for running custom functions in the background while the rest of the function stack continues to execute.

Types of Async Execution
Async
This option runs your functions asynchronously using your background task resources. Performance may vary based on other tasks being executed and the Xano plan you are currently on.
Async (dedicated)
This option is available for our Custom and Enterprise plans. It enables you to utilize dedicated resources to execute your custom functions asynchronously, and to specify the volume of resources to use. On a Custom or Enterprise plan, you have enhanced functionality to leverage these on-demand resources (instead of your background task resources) for each worker. Each function gets their own dedicated worker, with no queueing system. This allows you to support scenarios like parallel processing with thousands of workers, if necessary.
When choosing Async (dedicated), you'll have four options of resource allocation:

Small - Good for small operations with just a few data points or quick transformations
Medium - Handles more moderate workloads, such as working with a few hundred data points
Large - For larger datasets, such as working with thousands of points of data or database records
Custom - Allows you to define your own resource allocation if you have specific requirements
When using async functions, the function request history will still populate, so you can review the requests once they have finished executing. Each request will be labeled with the execution method.
Using Async Function Await
This function allows you to retrieve the output of a custom function executed asynchronously.
Insert a custom function into your function stack.
If you haven't built any custom functions yet, you can review our documentation on them here.
If necessary, retrieve the output of the async function.
If a function is set to async, it will return an ID that represents that execution, similar to the value shown below.
6f10cc09-d3e0-4ead-9a98-a0bc66bbe673
You can use the Async Function Await function to retrieve the output of the function once execution completes. Just provide it with an array of the ID(s) returned when the function runs.

Last updated
Was this helpful?