Custom code - API
function showModal(args, ctx) { ... }
Formulas
Formulas are synchronous, so you should not use Promises , Fetch or similar asynchronous APIs in your custom formulas. Instead, for such cases you can use an asynchronous custom action with a callback to another workflow with the value. You can then use the callback to set a variable that can be used in your formulas.
Please note: formulas written in code, only run/evaluate client side. This means you could see layout shifts when using custom formulas since they won't be evaluated correctly server side.
Root
Actions
-
The first is an object with the arguments that the action is called by. If your action has an argument called "foo" that is called with "bar", then your arguments object will look like `{ foo: "bar" }` -
The second argument is your current context. This context contains a function "triggerActionEvent" to trigger your events.
Trigger action event
function showModal(args, ctx) { ctx.triggerActionEvent("my-action-name", data) }
Warning: Formulas and actions can run any code you put into them, so be careful of malicious attempts when you paste code-snippets onto your app. Additionally, formulas should not contain side-effects, leave this to actions. If a formula is not a pure function then it might cause you some nasty bugs and reduce scalability and maintainability of your project.
Cleaning up after yourself