Running actions
Action formulas run when formula buttons are pressed. Unlike regular formulas that calculate values, action formulas make things happen. They enable complex workflows and business logic that go far beyond simple calculations.
What action formulas can do
Action formulas can handle sophisticated interactions like:
- Send reports only when data is valid, showing alert messages otherwise.
- Ask users a series of questions, then send reports incorporating their answers.
- Send multiple reports with different information to different recipients.
- Open reports on the user’s device while simultaneously sending messages to internal Slack channels. (Third-party integrations with Google Sheets, Excel, Salesforce and other services require platforms like Zapier.)
- Reset fields only after user confirmation, then navigate to the first screen and restore previously-hidden elements.
Action functions and syntax
Action formulas use 30 specialized action functions that do everything regular buttons can do and more. They also support the := assignment operator for setting property values. Both are exclusive to action formulas.
Here’s a simple example that asks for the user’s name and greets them:
Action formulas can perform multiple actions, either one after another or by waiting for one to complete before starting the next. They support conditional logic, allowing different actions based on varying conditions. This flexibility makes it possible to model complex business logic.
Action formulas attach only to the OnPress property of formula buttons.
Conditional logic with IF
Use functions like IF or SWITCH to perform different actions based on conditions.
This formula sends an email if all fields are valid and shows an alert message otherwise:
App.Fields.ValidApp,Fields,Valid returns a logical array where TRUE indicates a valid field and FALSE indicates an invalid field. AND returns TRUE only when all elements are TRUE, meaning all fields are valid.
Running multiple actions
Action formulas can perform any number of actions. Separate actions with ;;;.
This formula assigns values to two fields and hides a text box:
By chaining actions with ;;;, you can create buttons that only calculate values when pressed. For some apps, this offers an appealing alternative to automatic calculation as users type.
Navigation examples
This formula resets all fields and returns users to the first screen:
This formula assigns values to fields on SecondScreen before navigating there:
To restrict access to the second screen through the button only (not the Next button), set the NextScreenAvailable property of the preceding screen to FALSE.
Waiting for actions to complete
Many action functions take time to complete. EMAILREPORT, for example, sends reports by asking our server to create and send them, which takes a few seconds.
By default, EMAILREPORT starts the process and immediately continues to the next action. This formula starts sending a report and immediately shows a banner:
To perform an action after the report sends successfully, use the AWAIT function. This formula shows a completion banner once the report is sent:
Handling errors
The AWAIT function accepts three parameters: the action, a success handler and a failure handler. Only one of the latter two is required, so you can handle either success or failure exclusively.
This formula shows an error message if sending a report fails:
The OnFailure parameter is named, allowing us to omit the
success handler. Alternatively, use BLANK()BLANK() for the success
parameter:
The failure handler has access to a special Error value
containing detailed error information, including a user-friendly message.
When action functions fail without an OnFailure handler,
your app shows a default error message. To suppress all error messages
(including your own), pass BLANK()BLANK() as the
OnFailure parameter.
Next, learn about private apps that require users to sign in »