Actions

An action is a block of one or more logical operations, for example to navigate in an app, or to update data. Actions are in many ways equivalent to a function or method in traditional programming. Actions are a key element of building logic in Appfarm Create, in conjunction with conditions and functions, in order to tie the UI and data together. Actions are also an element of services.

Good to know

Actions in apps are run locally in the browser while actions in services run on the server.

The logical operations you can add to an action are called action nodes. Appfarm Create features a built-in library of action nodes that can be dropped into an action, each with customizable properties. These include if statements and foreach loops as well as data operations and advanced functionality such as generating PDFs and sending SMS.

As you add action nodes in sequence within an action, you construct the logical flow of what should happen under which circumstances. When the action is triggered, the action nodes will be run in order from top to bottom.

pageAction nodes

Triggers

An action is typically triggered by user behavior via an event handler, such as On Click. In this case, a Save button in a dialog might persist the data entered into a runtime data source and close the dialog. Another common trigger is the On App Load event handler.

Actions can also be triggered by other actions, using Run Other Action. This enables you to create an action once and re-use your logic across your app. Finally, actions can be triggered automatically using timers.

Debugging

Actions in an app are listed in Developer tools, which provides an easy way to test and debug actions using breakpoints. Any errors that occur will be reported in the client logs.

The Log to Console action node can be used to print data to the logs and console.log statements in functions will also be output.

Properties

Best practice

Use a verb when naming an action, for example Save event. This provides a quick description of what the action does. By including the object class event, it's easy to filter on actions which affect a specific object class.

Another alternative is to use the object class as a prefix, for example Event: Save. Since the list of actions is sorted alphabetically this has the benefit if listing all Event-related actions together.

PropertyDescription

Name

A descriptive name.

Description

A longer description of the service. For your own reference.

Pause Render

Pause UI updates while the action is running.

By default, when an action is triggered from the UI, for example by clicking a button, any UI changes triggered by the action will run as they occur. This can result in a poor user experience, or degraded performance. By enabling pause render, any UI changes will not occur until the action has finished running.

Skip Render

Do not update the UI after the action is finished. See Pause Render.

As an example, say you have enabled skip render and are displaying an App Variable with the value 1. If the action updates the value to 100, the UI will continue to display 1 even after the action has finished running.

Parallel Execution

Allow the action to fire multiple times in parallel. By default, an action will not run if the same action is already running for that user. This is to prevent the action firing multiple times when a user double clicks a button, for example.

Only enable parallel execution when needed and only on simple actions without heavy data processing or external API calls. One common case is when using On Hover Start and On Hover End to set a runtime boolean property to control visibility or styling in the UI.

Action Params

Action params

An action param defines a variable that can be used to pass a value into the action when it's triggered. Within the action, the value can be referenced via Context params which are available in conditions, filters, and functions.

Action params enable you to reduce the number of actions in an app. You can create actions with more generalized functionality, as the action can be provided context each time it's triggered. One frequent example is an action to change the views in an app. The action requires an action param with the data type View and a single action node, Navigate, set to navigate to the value specified in the action param. From throughout your UI, as well as from within other actions, you can call this action and specify the view you wish to navigate to as the action param value.

PropertyDescription

Name

A descriptive name.

Data Type

The type of data accepted as input for this parameter. See object classes for more information.

Required

Require that a value for this parameter is always specified when the action is triggered.

Default Value

Not available if Required is enabled.

Specify a default value to use in the case that a value is not provided when the action is triggered.

Last updated