> For the complete documentation index, see [llms.txt](https://docs.jigx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jigx.com/examples/readme/actions/execute-entities.md).

# execute-entities

`Execute-entities` is used to modify, create, and delete **multiple rows** in a specific table in a database.

{% hint style="warning" %}
Execute-entities can't be used if you're using [Static Data](https://docs.jigx.com/examples/readme/datasource/static).
{% endhint %}

## Configuration options

An `execute-entities` action can be used in multiple areas:

1. Under action button
2. In action list
3. In onPress/onChange events (if the component has these options)
4. In onRefresh/onFocus

Some properties are common to all actions, see [Common action properties](/examples/readme/actions/common-action-properties.md) for the list of actions and their configuration options.

## Reference data properties and values as a group

With the `execute-entities` action, you can reference data properties and values as a group instead of listing them individually to be saved or created. See the data-grouped example below:

{% tabs %}
{% tab title="data-grouped" %}

```yaml
actions:
  - children:
      - type: action.execute-entities
        options:
          title: Create Record(s)
          provider: DATA_PROVIDER_DYNAMIC
          entity: default/hikers
          method: create
          data: =@ctx.datasources.items
          onSuccess: 
            type: action.go-back
```

{% endtab %}

{% tab title="data-individual-listed" %}

```yaml
actions:
  - children:
      - type: action.execute-entities
        options:
          title: Create Record(s)
          provider: DATA_PROVIDER_DYNAMIC
          entity: default/hikers
          method: create
          goBack: previous
          data:
            contact: =@ctx.datasources.items.contact
            name: =@ctx.datasources.items.name
            email: =@ctx.datasources.items.email
            photo: =@ctx.datasources.items.photo
            participant-group: =@ctx.datasources.items.participant-group
```

{% endtab %}
{% endtabs %}

## Offline remote data handling

Dealing with offline remote data ensures consistent synchronization with the remote data source. It also lets users continue working without a connection. [Offline remote data handling](https://docs.jigx.com/building-apps-with-jigx/data/offline-remote-data-handling) explains the `queueOperation` property and provides examples.

### Group queued commands

Use `batchId` to group related queued writes. Group commands in the offline command queue. Commands sharing a `batchId` are processed top-to-bottom; if one fails, the remaining members of the batch are paused until the failed command is retried or deleted.

If a `sync` or `parallel` command fails, later commands in that batch pause. Retry or delete the failed command before continuing the batch. Failed `async` commands do not pause their batch.

Use `processingType` to control how the command is processed in the queue.&#x20;

<table><thead><tr><th width="136.6328125">Value</th><th>Behavior</th></tr></thead><tbody><tr><td><code>sync</code></td><td>Runs one command at a time. This is the default.</td></tr><tr><td><code>parallel</code></td><td>Starts with adjacent parallel commands. The next sync command waits for all of them.</td></tr><tr><td><code>async</code></td><td>Starts without waiting. Later commands can run immediately.</td></tr></tbody></table>

Omit both properties to retain the existing serial queue behavior.

`retry-queue-command` and `delete-queue-command` accept `batchId` as well as `id`, to act on a whole batch at once, plus an optional `force` (default `false`) needed to touch in-flight (`starting`/`processing`) rows, otherwise those are skipped.

The example groups related updates under `employee-update-42`. It sends two file updates concurrently. It then waits before updating the employees records.

```yaml
actions:
  - children:
      - type: action.action-list
        options:
          isSequential: true
          title: Update employees files and records
          actions:
            - type: action.execute-entities
              options:
                provider: DATA_PROVIDER_REST
                entity: employee-files
                method: update
                function: update-file
                queueOperation: add
                batchId: employee-update-42
                processingType: parallel
                data: =@ctx.datasources.pending-files
            - type: action.execute-entities
              options:
                provider: DATA_PROVIDER_REST
                entity: employees
                method: update
                function: update-employee
                queueOperation: add
                batchId: employee-update-42
                processingType: sync
                data: =@ctx.datasources.employee.{"id" :id}[]
```

## Examples and code snippets

### Execute-entities in action

{% columns %}
{% column %}

<figure><img src="https://1414514342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHcPzbms3kZejTmFd500V%2Fuploads%2FRvUwWHhsZFtQvlePFdhm%2Fac-executeEntities.png?alt=media&amp;token=843d14b5-afab-4ad8-af3c-febedd5d302a" alt="Execute entities" width="188"><figcaption><p>Execute entities</p></figcaption></figure>
{% endcolumn %}

{% column %}
**Example:** See the full example of execute-entities as an action in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/execute-entities/execute-entities-action.jigx).
{% endcolumn %}
{% endcolumns %}

{% code title="execute-entities-action" %}

```yaml
actions:
  - children:
    - type: action.execute-entities
      options:
        title: Add user
        provider: DATA_PROVIDER_DYNAMIC
        method: create
        entity: default/form
        data:
          firstname: =@ctx.datasources.employee-detail-dynamic.firstname
          lastname: =@ctx.datasources.employee-detail-dynamic.lastname
```

{% endcode %}

### Execute-entities in action list

**Example:** See the full example of execute-entities in an action list in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/execute-entities/execute-entities-actionlist.jigx).

{% code title="execute-entities-action-list" %}

```yaml
actions:
  - children:
      - type: action.action-list
        options:
          isSequential: true
          title: Add user
          actions:
            - type: action.execute-entities
              options:
                provider: DATA_PROVIDER_DYNAMIC
                method: create
                entity: default/form
                data:
                  firstname: =@ctx.datasources.employee-detail-dynamic.firstname
                  lastname: =@ctx.datasources.employee-detail-dynamic.lastname
            - type: action.info-modal
              options:
                modal:
                  title: User successfully added  
                  buttonText: See user list
                  element: 
                    type: icon
                    icon: add-circle-bold-alternate
                    color: element
                onConfirmed: 
                  type: action.go-to
                  options:
                    linkTo: execute-entities-onPress
```

{% endcode %}

### Execute-entities in onPress/onChange event

Here is the example of execute-entities in onPress/onChange event in [list-item](/examples/readme/components/list/list-item.md).

<figure><img src="https://1414514342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHcPzbms3kZejTmFd500V%2Fuploads%2FGbFzAPsYODet5OzXGSih%2Faction-EEntitiesPress.PNG?alt=media&amp;token=238ed5f5-e403-42bb-a5aa-02437b60f3b5" alt="Execute-entities" width="375"><figcaption><p>Execute-entities</p></figcaption></figure>

**Example:**

See the full example of execute-entities in action onPress in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/execute-entities/execute-entities-onPress.jigx) See the full example of execute-entities in action onChange in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/execute-entities/execute-entities-onChange.jigx)

{% tabs %}
{% tab title="onPress" %}

```yaml
onPress: 
  type: action.execute-entities
  options:
      provider: DATA_PROVIDER_LOCAL
      method: update
      entity: default/employees
      data: 
        id: =@ctx.current.item.id
        modify: =($number(@ctx.current.item.modify) + 1) 
```

{% endtab %}

{% tab title="onChange" %}

```yaml
onChange: 
  type: action.execute-entities
  options:
    provider: DATA_PROVIDER_LOCAL
    method: update
    entity: default/employees
    data: 
      id: =@ctx.current.item.id
      modify: =$number(@ctx.current.item.modify) + 1
```

{% endtab %}
{% endtabs %}

### Execute-entities in onRefresh/onFocus

<figure><img src="https://1414514342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHcPzbms3kZejTmFd500V%2Fuploads%2FSOKtZ8Dv0r5QAXpjUrAb%2FactionEEnitiesOnFocus.PNG?alt=media&amp;token=10e9ecec-afca-4ed7-b78a-676429e48d51" alt="Execute-entites" width="375"><figcaption><p>Execute-entites</p></figcaption></figure>

**Example:**

See the full example of execute-entities in onRefresh in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/execute-entities/execute-entities-onRefresh.jigx). See the full example of execute-entities in onFocus in [GitHub](https://github.com/jigx-com/jigx-samples/blob/main/quickstart/jigx-samples/jigs/jigx-actions/execute-entities/execute-entities-onFocus.jigx).

{% tabs %}
{% tab title="execute-entities-onRefresh" %}

```yaml
onRefresh: 
  type: action.execute-entities
  options:
    provider: DATA_PROVIDER_LOCAL
    method: update
    entity: default/employees
    data: =@ctx.datasources.employee-detail-dynamic.{'id':id, 'modify':$number(modify)+1}
```

{% endtab %}

{% tab title="execute-entities-onFocus" %}

```yaml
onFocus: 
  type: action.execute-entities
  options:
    provider: DATA_PROVIDER_LOCAL
    method: update
    entity: default/employees
    data: =@ctx.datasources.employee-detail-dynamic.{'id':id, 'modify':$number(modify)+1}
```

{% endtab %}
{% endtabs %}

### Deleting multiple data records using execute-entities

To delete multiple data records in a Dynamic data table use the execute entities action with an expression as shown below.

{% hint style="info" %}
This code example is **not** in the jigx.samples solution in GitHub.
{% endhint %}

**Example:**

{% code title="Execute-entities-multiple" %}

```yaml
actions:
  - children:
      - type: action.execute-entities
        options: 
          title: Delete employees
          provider: DATA_PROVIDER_DYNAMIC
          entity: default/employees
          method: delete
          data: =@ctx.datasources.employee.{"id" :id}[]
```

{% endcode %}

### Updating multiple data records using execute-entities

To update multiple data records in a Dynamic data table use the execute entities action with an expression as shown below.

{% hint style="info" %}
This code example is **not** in the jigx.samples solution in GitHub.
{% endhint %}

**Example:**

```yaml
actions:
  - children:
      - type: action.execute-entities
        options:
          title: Update Records
          provider: DATA_PROVIDER_DYNAMIC
          entity: default/penguin_species
          method: update
          data: =@ctx.datasources.penguin-species ~> | $ | {"endangered":"Yes"} |    
```

### Updating multiple data records in a single REST call

See [Update multiple records in a single REST call](/examples/readme/data-providers/rest/create-an-app-using-rest-apis/update-multiple-records-in-a-single-rest-call.md) for an example of using execute-entities with REST.


---

# 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.jigx.com/examples/readme/actions/execute-entities.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.
