Custom Functions
Last updated
Last updated
These are Functions that are created and displayed in the Library or installed from the Marketplace.
Custom Functions enabled you to build your own functions using the same workflow as the No Code API Builder. Just like the No Code API Builder, custom functions have inputs, the function stack, and the response. However, instead of an API endpoint URL, custom functions can be inserted into function stacks anywhere in your Xano workspace (API endpoints, other custom functions, or background tasks).
Once you create a custom function from the library, you can insert it into any function stack when you select custom functions when adding a new function.
If there are any inputs, you will need to map them for the function to run.
Building a custom function is just like building an API Endpoint.
Once you have created a custom function, you can add it to any function stack in your workspace by selecting Custom Functions when adding a function stack item.
Once selected, you can choose from any of the custom functions in your workspace.
You can also convert existing function stacks to custom functions by selecting the steps you want to include in the custom function and clicking the "Convert to Func" button.
Like API Endpoints, custom functions have request history. Read more here.
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 an 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.
To enable asynchronous 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 means that the function stack will wait for the custom function to execute before continuing. The custom function will output the result to the defined variable. This is the standard behavior that has always existed for custom functions.
Async means that the functions will be queued for execution using your background task resources. The function's output variable will be populated with a unique identifier for the queued excecution.
Async (dedicated) is available for Enterprise plans and gives you a method of specificity around the resources used to execute the custom function.
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.
In scenarios where you want to use the output of your async functions later in the function stack, you can utilize the Async Function Await function, which accepts the UUIDs returned when an async function is executed.
You can provide an array of IDs to get the output of, and specify how long you'd like to wait for those functions to finish executing in seconds using the timeout parameter.