> For the complete documentation index, see [llms.txt](https://docs.amltd.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.amltd.com/dc-works/applets/actions-events-and-conditions.md).

# Actions, Events, and Conditions

Learn how to make an Applet respond to user input, load and save data, navigate between pages, and perform operations only when specified conditions are met.

Actions define what an Applet does. Events determine when those actions run. Conditions determine whether particular actions should run.

For example:

* **Event:** The user selects a button.
* **Condition:** The selected equipment’s Status equals Available.
* **Action:** Navigate to the Equipment Checkout page.

\[Insert video: Introduction to actions, events, and conditions]

### Understand actions, events, and conditions

These three components work together to control Applet behavior.

#### Event

An event is something that occurs while the Applet is running.

Examples include:

* A page opening.
* A barcode being scanned.
* Keyboard entry being received.
* A button being selected.
* A Table View row being selected.
* A value being entered in an input field.

The event starts its configured action sequence.

#### Action

An action is an operation performed by the Applet.

Actions can be used to:

* Show, hide, enable, or disable a field.
* Set or clear a value.
* Navigate to another page.
* Load or search database records.
* Add or update a record.
* Transform text.
* Display a message.
* Play a sound.
* Perform calculations.
* Call an API.

#### Condition

A condition evaluates a value before one or more actions run.

Conditions allow an Applet to respond differently according to:

* User-entered information.
* Record values.
* Field values.
* Device or user information.
* Barcode data.
* Dates and times.
* Other values available to the Applet.

{% hint style="info" %}
An event starts the sequence, a condition makes a decision, and an action performs the operation.
{% endhint %}

### Where actions can be added

Actions can be added to pages, fields, and workflows. The available event locations depend on what is selected in the Applet Editor.

### Page actions

Select a page and open **Actions** in the Properties Panel to display its page-level action settings.

#### Page Load Actions

**Page Load Actions** run when the page opens or reloads.

They are commonly used to:

* Load records into a Table View.
* Look up information needed by the page.
* Reset a working record.
* Populate initial field values.
* Show, hide, enable, or disable fields.
* Set focus on the first input field.

Page Load Actions also run when the page is opened through **Go To Page** or **Previous Page** and when **Refresh Page** reloads the current page.

#### Scan Actions

**Scan Actions** run when barcode data is received while the page is active.

They can be used to:

* Look up a scanned item.
* Place barcode data in a field or record.
* Validate a barcode.
* Navigate to another page.
* Add or update a record.

#### Keyboard Actions

**Keyboard Actions** run when keyboard entry is received while the page is active.

They can be used to process information entered through a physical or on-screen keyboard.

#### Workflows

A workflow is a named, reusable sequence of actions configured from the page’s **Actions** properties.

Workflows are useful when the same set of operations may need to run from multiple locations. Use **Run Workflow** to start a workflow.

Timer workflows can be restarted using **Reset Timer Workflow**.

### Field actions

Select a field and open its **Actions** properties to display the events supported by that field type.

#### Button Click Actions

A Button’s **Click Actions** run when the user selects the button.

Buttons are commonly used to:

* Submit information.
* Add or update a record.
* Navigate to another page.
* Display a message.
* Run a workflow.

#### Table View Row Click Actions

A Table View’s **Row Click Actions** run when the user selects a row.

They can be used to:

* Place the selected row’s values in a single working record.
* Display the selected record’s details.
* Navigate to another page.
* Prepare a record for updating or deleting.

The **Select Table Row** action can also select the first Table View row and execute its configured Row Click Actions.

#### Input Actions

An input field’s **Input Actions** run when the field receives an input value.

They can be used to:

* Validate the value.
* Look up a matching database record.
* Set another field or record value.
* Move focus to another field.
* Add a completed record.
* Navigate to the next step.

Populating a bound field through **Set Field** also executes that field’s configured Input Actions.

Other supported field types display their applicable action settings under **Actions** in the Properties Panel.

<figure><img src="/files/LHqg86i3xBhwvIg4Ld0v" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/mW2Pslvp3zaKyTcNNDEt" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/BDvsQrZAXFwFeQUQcivj" alt=""><figcaption></figcaption></figure>

### Add an action

To add an action:

1. Open the page or field properties containing the required event.
2. Select **Edit** for the event.
3. Select **Action**.
4. Select an action category.
5. Select the specific action.
6. Configure the action’s required values.
7. Select **OK**.
8. Review the action sequence.
9. Select **OK** again to close the action editor.
10. Save the Applet.

<figure><img src="/files/eqg5l7FhmqLRj5KoXNzW" alt=""><figcaption></figcaption></figure>

The settings displayed depend on the selected action. For example:

* **Go To Page** requires a destination page.
* **Set Field** requires a field and value.
* **Load Table** requires a Table View.
* **Add Record** requires a record.
* **Popup Message** requires a title, message, and button text.

### Action categories

The Action editor organizes the available actions into five categories.

| Category       | Purpose                                                                        | Examples                                             |
| -------------- | ------------------------------------------------------------------------------ | ---------------------------------------------------- |
| **Field**      | Controls field appearance, availability, focus, and values                     | Show Field, Disable Field, Set Field, Clear Fields   |
| **Navigation** | Controls movement through or out of the Applet                                 | Go To Page, Previous Page, Refresh Page, Exit App    |
| **Data**       | Loads, searches, changes, synchronizes, or processes records                   | Load Table, Lookup Record, Add Record, Update Record |
| **Text**       | Parses, combines, formats, or modifies text values                             | Parse, Combine, Replace, Trim, Date Format           |
| **Custom**     | Performs device, interface, calculation, scripting, and integration operations | Popup Message, Math, Play Sound, API Call            |

The complete list of available actions and their purposes is provided separately in **Action Reference**.

### Configure action values

Each action requires one or more values that identify what the action should operate on.

Depending on the action, a value may come from:

* Static text.
* An Applet record.
* An environment record.
* A field on the current page.
* A database table.
* Another available source.

For example, **Set Field** can populate an Input field using:

* A fixed value.
* A value from another record.
* The current user’s information.
* The device serial number.
* The current date or time.
* Previously captured barcode data.

Confirm that the selected value source contains the expected information before the action runs.

### Action execution order

Actions execute sequentially from top to bottom.

The order is important when one action depends on the result of another.

For example:

1. **Lookup Record** retrieves an equipment record.
2. **Set Field** displays a value from that record.
3. **Go To Page** opens the detail page.

If the navigation action runs before the record is retrieved, the destination page may not have the expected information.

#### Reorder actions

To change the execution order:

1. Open the applicable action editor.
2. Select the action to move.
3. Select **Move actions up** or **Move actions down**.
4. Confirm that the actions appear in the required sequence.
5. Select **OK**.
6. Save the Applet.

<figure><img src="/files/GGR2eHfYR7BdOR2xj5nF" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Place actions that retrieve or prepare data before actions that display, evaluate, save, or navigate using that data.
{% endhint %}

### Edit or delete an action

To edit an existing action:

1. Select the action in the action editor.
2. Select **Edit**.
3. Change its configuration.
4. Select **OK**.

To delete an action:

1. Select the action.
2. Select **Delete**.
3. Confirm the deletion if prompted.

Save the Applet after changing its action configuration.

### Copy an action sequence

The clipboard control can copy an action sequence, including its conditions and contained actions.

This is useful when similar behavior is needed in another event or on another page.

After copying the sequence:

1. Open the destination action editor.
2. Use the clipboard control to paste the copied actions.
3. Review every field, record, page, and value used by the pasted actions.
4. Reorder or edit them as needed.
5. Save the Applet.

{% hint style="warning" %}
Copied actions retain their existing configuration. Confirm that all referenced fields, records, and pages are appropriate for the destination.
{% endhint %}

### Add a condition

Conditions allow actions to run only when specified criteria are met.

To add a condition:

1. Open the applicable action editor.
2. Select **Condition**.
3. Select the **Condition Type**.
4. Select the value to evaluate.
5. Select the comparison operator.
6. If required, select or enter the comparison value.
7. Select **OK**.
8. Add or move the required actions beneath the condition.
9. Confirm that the contained actions appear indented under **Then**.
10. Save the Applet.

<figure><img src="/files/Nfj6vyWXhT1YKkhR0kaK" alt=""><figcaption></figcaption></figure>

### Condition types

DC Works provides three condition types.

#### If

**If** begins a conditional sequence.

When its comparison is true, the actions contained under **Then** run. When it is false, those actions are skipped.

#### Else if

**Else if** evaluates another comparison when the preceding **If** or **Else if** comparison is false.

Multiple Else if branches can be used to test additional possibilities.

#### Else

**Else** does not require a comparison. Its actions run when the preceding If and Else if comparisons are false.

A conditional sequence can therefore provide different behavior for several possible results.

### Condition values

Conditions can evaluate values from several sources.

#### Applet records

Record values can be used to make decisions based on the Applet’s working data.

Examples include:

* Equipment record.Status.
* Equipment record.Assigned To.
* Equipment record.Location.

#### Environment records

Environment records provide information about the current user, device, Applet, and captured input.

Available values can include:

* User Name.
* User Department.
* User Location.
* User Title.
* User Tag.
* Device Serial Number.
* Device Model.
* Date String.
* DateTime String.
* Time String.
* App Version.
* Web Version.
* Applet Version.
* Barcode.
* Barcode Type.
* Barcode Field.
* Keyboard Entry.

#### Page fields

A condition can evaluate the current value of a field on the page.

For example, it can determine whether:

* An Input field is empty.
* A Checkbox is selected.
* A field contains a specific value.
* A numeric value exceeds a limit.

### Condition operators

The available operators include:

| Operator                  | Purpose                                                                 |
| ------------------------- | ----------------------------------------------------------------------- |
| **Is Empty**              | Checks whether the selected value contains no information               |
| **Is Not Empty**          | Checks whether the selected value contains information                  |
| **Equals**                | Checks whether two values are equal                                     |
| **Not Equals**            | Checks whether two values are different                                 |
| **Contains**              | Checks whether the selected value contains the comparison value         |
| **Not Contains**          | Checks whether the selected value does not contain the comparison value |
| **Starts With**           | Checks the beginning of a text value                                    |
| **Ends With**             | Checks the end of a text value                                          |
| **Greater Than**          | Checks whether the selected value is greater than the comparison value  |
| **Greater Than Or Equal** | Checks whether it is greater than or equal to the comparison value      |
| **Less Than**             | Checks whether the selected value is less than the comparison value     |
| **Less Than Or Equal**    | Checks whether it is less than or equal to the comparison value         |

**Is Empty** and **Is Not Empty** do not require a second comparison value.

### Place actions inside a condition

Actions belonging to a condition appear indented beneath it and are identified as **Then** actions.

Use the horizontal movement controls to move a selected action into or out of a conditional branch. Use the vertical movement controls to change its execution order within the sequence.

<figure><img src="/files/5sdKgzntikD0QsNOZJYr" alt=""><figcaption></figcaption></figure>

Review the indentation carefully. An action placed outside the condition runs regardless of whether the comparison is true or false.

### Example: check equipment availability

Suppose the user selects an equipment item and its information is placed in **Equipment record**.

A Button’s Click Actions could use this conditional sequence:

1. **If**
   * Value: Equipment record.Status
   * Operator: Equals
   * Comparison value: Available
2. **Then**
   * Go to the Equipment Checkout page.
3. **Else if**
   * Value: Equipment record.Status
   * Operator: Equals
   * Comparison value: Maintenance
4. **Then**
   * Display a message explaining that the item is being serviced.
5. **Else**
6. **Then**
   * Display a message explaining that the item is unavailable.

The Equipment record must be populated before the condition evaluates its Status.

### Actions and data binding

Actions frequently operate on records connected to fields through data binding.

For example:

1. The user enters an Equipment ID.
2. An Input Action runs **Lookup Record**.
3. The matching database entry is placed in **Equipment record**.
4. Bound fields display the equipment information.
5. The user changes the Status and Assigned To fields.
6. Data binding updates the working record.
7. A Button Click Action runs **Update Record**.
8. The changes are written to the database table.

{% hint style="warning" %}
A value appearing correctly in a bound field does not mean it has been saved to the database. Confirm that the action sequence includes the appropriate Add or Update action.
{% endhint %}

### Test actions and conditions

After configuring actions:

1. Save the Applet.
2. Run it on a device or as a Web App.
3. Trigger the configured event.
4. Confirm that the actions run in the intended order.
5. Test each condition branch.
6. Test empty, invalid, and unexpected values.
7. Confirm database changes from the table’s Records page.
8. Test device-dependent operations on supported hardware.

If the Applet does not behave as expected, confirm:

* The action was added to the correct event.
* The actions are in the correct order.
* The required record was populated before use.
* Fields are bound to the correct record values.
* The condition uses the correct value and operator.
* The action is located inside the intended conditional branch.
* The Applet was saved after the latest changes.

### Next

Continue to **Action Reference** for a categorized list of the available Field, Navigation, Data, Text, and Custom actions and a summary of what each action does.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.amltd.com/dc-works/applets/actions-events-and-conditions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
