Add, modify, or delete data values and records in tables by adding the Change data task to a bot.

Configure the properties for the Change data task as described in the following table. For examples, see Examples of changing data.

Property

Description

Task name

Name of the task. It must be unique within your app.

Table name

Table referenced by the task. Select an existing table in the list.

Click View definition to view the structure of the selected table.

See Tables: The Essentials for more information about adding tables.

Data Change Action Name

Data change action to be taken on the selected table.

See Actions: The Essentials for more information about adding actions.

When you are done, save the task by selecting one of the following:

  • Save - Save the task

  • Save & verify data - Save the task and verify the data defined.

  • Save & notify users - Save the task and notify users.

After you save the task, you can reuse it in other bots.

Examples of changing data

The following sections provide examples of how to change data values and records in tables in a bot.

The following tables are used by the apps in the examples:

  • Two tables: Projects and Employees

  • Each row in the Projects table describes a single project and each row in the Employees table describes a single employee.

  • The Projects table references the Employees table to assign a project to an employee.

Example: Changing data values in a table

This example demonstrates how to create a bot to change data values in a table.

For example, configure your app so that each time a new project is added to the Projects table the status of the employees assigned will be automatically updated to Assigned in the Employees table.

1. Create an action and configure the following properties:

Property

Setting

Action name

Update Employee Status

For a record of this table

Employees

Do this

Data: set the values of some column in this row

Set these columns

Configure the column name and expression value to set the employee status to Assigned.

2. Create an action and configure the following properties:

Property

Setting

Action name

Get Employees to Update

For a record of this table

Employees

Do this

Data: execute an action on a set of rows

Referenced Table

Employees

Referenced Rows

Set to an expression that returns a list of row keys from the Employees table. The row keys will be used by AppSheet to identify the employees to be updated.

For example, to select the employee that has been assigned to the current project, use the expression:

LIST([Employee ID])

Referenced Action

Update Employee Status

3. Configure the data change task, as follows:

Property

Setting

Task Name

On Adding New Project

Table name

Projects

Data Change Action Name

Get Employees to Update

With this configuration, each time a new project is added to the Projects table:

  1. The On Adding New Project change data task will be triggered.

  2. The On Adding New Project task will invoke the Get Employees to Update action, which will select the employees to be updated from the Employees table.

  3. The Update Employee Status action will be applied to the employees identified and change the employee status to Assigned.

Example: Adding a record to a table

This example demonstrates how to create a bot to add a record to a table.

For example, configure your app so that each time a new employee is added to the Employees table a new Project is added to Attend new employee orientation.

1. Create an action and configure the following properties

Property

Setting

Action name

Create Orientation Project

For a record of this table

Employees

Do this

Data: add a new row to another table using values from this row

Table to add to

Projects

Set these columns

Set the column values for the new Attend new employee orientation project record. Click Add to add additional columns.

2. Configure the data change task, as follows:

Property

Setting

Task Name

On Adding New Employee

Table name

Employees

Data Change Action Name

Create Orientation Project

In this scenario, each time a new employee is added to the Employees table:

  1. The On Adding New Employee change data task will be triggered.

  2. The On Adding New Employee task will invoke the Create Orientation Project action, which will add an Attend new employee orientation project to the Projects table.

Did this answer your question?