A workflow rule can be used to:

  1. Change one or more data values in one or more tables.
  2. Add one or more records to one or more tables.
  3. Delete one or more records from one or more tables.

Change One or More Data Values in Another Table

Suppose your app has a Projects table and an Employees table. 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, which means that each project must be assigned to one employee. You want to design the app such that every time a new project is added, the status of the corresponding employee will be automatically updated to Assigned. To do this:

  1. Create an action: Set Action name to Update Employee Status. Set For a record of this table to the Employees table. Set Do this to Data: set the values of some column in this row. Configure the column and value to set the employee's status to Assigned.
  2. Create an action: Set Action name to Get Employees to Update. Set For a record of this table to the Employees table. Set Do this to Data: execute an action on a set of rows. Set Referenced table to the Employees table. Set Referenced Action to Update Employee Status. Set Referenced Rows 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])
  1. Create a workflow rule: Set Rule name to On Adding New Project. Set Target data to the Projects table. Set Update event to ADDS_ONLY. Set Reaction to Change Data. Set Workflow Action Name to Get Employees to Update. Set Data Change Action Name to Update Employee Status.

Each time a new project is added to the Projects table, the On Adding New Project workflow will be triggered. This workflow will invoke the action Get Employees to Update, which will select the employees to be updated from the Employees table. Once the employees have been selected, the action Update Employee Status will be applied to each selected employee, which will change the employee's status to Assigned.

Adding a Record to Another Table

Suppose your app has a Projects table and an Employees table. 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, which means that each project must be assigned to one employee. You want to design the app such that every time a new Employee is added, a new Project is added to "Attend new employee orientation". To do this:

  1. Create an action. Set Action name to "CreateOrientationProject". Set For a record of this table to the Projects table. Set Do this to "Data: add a new row to another table using values from this row." Set the appropriate column values for the added row.
  2. Create a workflow rule. Set Rule name to "On Adding New Employee". Set Target data to the Employees table. Set  Update event to "ADDS_ONLY". Set Reaction to "Change Data". Set Workflow Action Name to "Add Orientation". Set Data Change Action Name to "CreateOrientationProject".

Did this answer your question?