The Update fields in Table action allows you to edit one or more records in a specified table.
Note: This action is for updating records which already exist. If you wish to create a brand new record via an action, you will need to use Insert Records into Table.
This action, once completed, is permanent. There is no way to undo any changes this action does.
How To Use Update Fields in Table
This action requires the following parameters to be filled:
- Select a table: the table holding the records to update
- Update records where: specifies how to select which record or records to update within the table. This is done using the criteria builder.
- Field(s) to update: choose one or more field(s) which will be updated.
- Update using this value: specify the values to update each field. This can be manually entered or pulled from a control, session variable, or an action result.
This action isn't the only way to update a record in a Method table (often, the Save All action is used to save a record from a user-facing screen), but it is a way for Method to automatically save a record as part of an action sequence.
In this scenario, we are customizing the activities list. A checkbox column has been added to the activities grid and we want a button to set all the selected activities as completed.
The "Complete Selected Activities" button has been dragged onto the screen, and in its Click Event, there are two actions:
- Loop Through Grid: This action will loop through the grid, but only through the records which have been checked. For more information on this action, please see our article Loop Through Grid.
- Update Fields in Table: This action will update the the ActivitiesStatus field which we will cover in detail below.
When selected, the Update Fields in Table action has been configured as shown below:
- Select a table: the Activity table has been selected since we hope to complete activities.
- Update records where: In this given example, will go through each selected record in the grid (which there are two of). The criteria will then do a comparison: does the RecordID that we are currently looping through match a record in the Activity table?
- Field(s) to update: If the criteria results in true, in other words, if the RecordID of a record is either 454, or 456, then that recorded will have its ActivityStatus field updated.
- Update using this value: We want this activity to be set to complete, so we set the ActivitiyStatus field to "Completed", which we have manually typed in.
To explain it plainly, this is what happens when a user clicks the "Complete Selected Activities" button.:
- Loop through the grid searching for records which have been checked.
- The first record in the looped-through grid is 454.
- In the action Update Fields in Table, it finds the record with the RecordID 454 in the Activity Table.
- Once found, it then updates this record's ActivityStatus field with the text "Completed".
- The above is now complete so we continue through the loop and find the next checked record, 456.
- Repeat the Update Fields in Table action again for this grid row, this time looking for the RecordID 456 in the Activity Table.
- Once found, this record's ActivityStatus field is updated to Completed.
- This action is complete so we return back to the loop, but there are no more checked rows in the grid, so the action set ends!
The two activities are now completed. There are a number of ways you can improve this process, but the main point of this example is to showcase the Update Fields in Table action.
However, for those of you who are interested in making this user friendly:
- Consider a confirmation message to make sure the user wishes to make this change.
- Consider a completion message to make sure the user knows the process is complete.
- Refresh the grid to reflect changes.