Update Current Record Action

image\Action_Database_Update_Record.jpg

The Update Current Record action is used to amend (update) the current record displayed in a query’sSelect List with new information. For example, if the Select List contains 10 records and the fifth record is currently open, this action will update the fields of the fifth record with new information. The new information can be added to the field as: plain text (i.e. the String option); the contents of an Opus variable (i.e. the Variable option); reset to a blank entry (i.e. the Null option); or ignored (i.e. the Don’t Update option).

Note:
This action is used to update existing records in a table of a database. If you want to create a new record use the Insert New Record action.

Important Note!

This action will only work if the Select data for Updating/Deleting option in the SQL Wizard was ticked for the query selected in option 2 below – see Creating a Query – The SQL Wizard for more information.

Setting up the Update Current Record action:

1. Add the Update Current Record action to your trigger, as described in adding actions. The Update Current Record tab will automatically appear when you add the action.

2. Click on the down arrow to the right of the Query box to open a list of query’s you have previously created in this publication. Once you select a query the Field / Set To panel below this option is activated – this will show the fields of the table in the database in the Field column and the field variable to which this field was assigned to in the Set To column.

Note:
If the drop down box is empty, you have not previously entered a Database Query action to this publication. You must have created at least one Database Query action in order for this action to work.

3. Use the Field / Set To panel to select which fields in the current record you want to update. To update the contents of a field, select the field name in the Field column and click on one of the following radio buttons: String, Variable, Null or Don’t Update. Repeat this exercise for each field listed in the Field column. By default each field is set to the value of the field variable.

4. Use the String option to type a new value for the selected field. Any letter, number, word or phrase can be typed into this field.

Note:
The name tag String is context sensitive. This means the name tag will change depending on what the field in the table of the database is allowed to contain (e.g. if the field can only contain numbers then this name tag will appear as Numbers).

5. Use the Variable option to copy the contents of an Opus variable into the field of the current record. Click on the down arrow to the right of the Variable box to display a list of all the variables in the current publication.

Note:
This option is useful when you want the value a user has entered to be stored in the field. For example, you could create an Input Text object on the page – this automatically saves whatever the user types into a specified variable – this variable could be used here in this action.

6. Use the Null option when you want to remove the current entry for the field with a blank entry.

7. Use the Don't Update option when you want the field to be ignored during this action. In other words, the contents of the selected field remain the same.

8. Remember, for each field that is listed in the Field column, you must select one of the radio buttons described in points 4 to 7 above.

9. Click on the Apply button to save your changes.

Note:
This action will NOT ask for confirmation before it updates the record. To ensure a record is not accidentally updated from a database, we recommend that you create an If or Loop action that requires a user response of Yes or No before using the Update Current Record Action.

Related Topics:

Working with Databases - Overview

Introducing the Database Actions

Showing Records from a Database in Opus

Choosing an Action