Edit Records

Before you begin

App users cannot edit data directly on the table. Ensure that you have linked appropriate widgets to receive the table row data for editing and updating to the table. See Add Rows to a Table Using a Table Block and Prepare Widgets for Record Editing.

Prepare the Blockly Code

About this task

To edit table records, perform the following:

Procedure

  1. In the Canvas, click the table widget in your app.
  2. In the Table Properties panel, under the Actions section, select the Edit Records checkbox.
  3. Below the checkbox, under Configure Blockly Script, click the Add button. The Blockly editor will open.
  4. In the Blockly Name field, enter a name for the Blockly script.
  5. In the Blockly editor's left-hand panel, click the Connections group and drag a connection block into the main area.
    Connection block with default settings
  6. In the REST dropdown, select PUT to allow changes to be updated on the data source.
  7. Click the Text group, and drag the create text with block to the connection block, and drop it in the URL field.
    Connection block configured for PUT and the create text with block
  8. Click the Text group again, drag the white quote bubble to the connection block, and drop it in the first open field within the create text with block. In the white quote bubble, enter the address of the database API (Application Programming Interface) connection.
    Connection block configured with the address
  9. Click the Table group, drag the selected row block to the connection block, and drop it in the remaining open field within the create text with block. In the selected row dropdown, choose the name of the table to edit. In the column dropdown, select the column that uniquely identifies the record.
    Connection block configured for the table row
  10. To update the data on the table after an edit is committed, you will need to request a refresh. Click the Table group, and drag the refresh table block to the on success section of the connection block. From the refresh table dropdown, select the name of the table to be refreshed.
    Connection block configured to refresh the table
  11. To link source data with the edited fields, perform the following:
    1. Click the Data button. Beside the JSON dropdown, click the Add button.
      Connection block configured with empty field mapping for committing data
    2. In the key text block (white quote bubble), enter the name of the first data field as identified in your data source.
    3. Click the Widget Values block group, and drag the get textboxes block to the value block.
    4. In the get textboxes dropdown, select the name of the widget that will hold the edited value of the first data field.
    5. Click the Add button, and repeat this step for all edited fields.
      Connection block configured with all fields mapped for committing data
  12. Click Save. You will return to the Canvas.
  13. Select Save in the SOTI Snap banner to apply your changes.
    Save app button

Test the Blockly Code

About this task

To test your Blockly code, perform the following:

Procedure

  1. In the Canvas, click the preview button to run the app. The Preview Options window will open.
    Image of the preview button
  2. Click Preview to accept the default skin. The app will open.
  3. Select a table row, and click the More button. Click Edit. Cancel and Save buttons will appear below the table.
    Edit and delete options of the More button
  4. The row data will populate the linked widgets. Edit the content in each field. Click Save.
    Example of row data copied to linked widgets

Results

Changes to records should be reflected in the table's row data. If not, check the steps taken under Prepare Widgets for Record Editing and Prepare the Blockly Code above.