Custom Functions
Last updated
Last updated
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.
Building a custom function is just like building an API. Refer to that documentation for specific instructions on building the function stack.
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.