Application

Data Table Trigger Node

The Data Table Trigger fires a workflow whenever a row is added, updated, or removed from a given Data Table.

Data Table Trigger

Node Properties

There are two configurable properties for the Data Table Trigger …

Data Table

First, select which Data Table the trigger should fire on when one or more of the selected actions is applied to the table.

Trigger Actions

Next, choose one or more actions applied to the Data Table that should fire the trigger. At least one action is required. You may fire the trigger on the following actions:

Trigger on a single row insertion

The trigger will fire whenever a single row is added to the Data Table …

  • By clicking the “Add Row” button in the table’s interface.
  • By importing a CSV with a single row in the table’s interface.
  • By invoking a Table: Insert Rows Node with just a single new row …

    • Through the “Individual Fields” option.
    • Through the “Payload Path” or “JSON Template” option, providing either an object for the new row or an array containing a single new row object.
  • Through the Data Table Rows: Post API endpoint with a single new row (either as an object or as an array with a single entry).

Trigger on a bulk row insertion

The trigger will fire whenever multiple rows are added to the Data Table …

Note: When importing a CSV, the Losant interface may break the contents of larger files up into multiple requests. This will result in the Data Table Trigger firing multiple times for a single file import.

Trigger on a single row update

The trigger will fire whenever updating one or more values in a Data Table row …

Note: The trigger will not fire if the updates applied to the row do not result in any value changes (for example, setting one column’s value to “hello” when the value in the row is already “hello”).

Trigger on a single row deletion

The trigger will fire a single time whenever deleting a Data Table row …

The trigger will fire multiple times (once per row) in the following scenarios …

  • By providing a query that does not automatically match all rows and then selecting the “Delete Rows” option through the table’s interface.
  • By invoking a Table: Delete Rows Node with a “Query Template” that matches multiple rows and when providing a “Limit Template” greater than 1 in the configuration.
  • Through the Data Table Rows: Delete API endpoint with a query that resolves to multiple rows and when providing a “limit” greater than 1 in the request.

Note: The trigger will fire a maximum of 10,000 times in the scenarios described above.

The trigger will not fire in the following scenarios …

  • By providing a query that automatically matches all rows and then selecting the “Delete Rows” option through the table’s interface. (The confirmation modal will include this notice that Data Table Triggers will not fire for these types of queries.)
  • Through the Data Table Rows: Truncate API endpoint.

Payload

Depending on the action that caused the trigger to fire, the shape of the workflow’s initial payload changes significantly.

Single Row Insertion

When inserting a single row, the payload includes the details about the new row under the data property.

{
  "data": {
    "action": "insert",
    "newRow": {
      "createdAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST) // Date object for when the row was created
      "id": "<ID of the newly created row>",
      "updatedAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST), // Date object with the same value as "createdAt"
      ...keys and values for each column in the new row
    }
  },
  "applicationId": "<ID of the current application>",
  "applicationName": "<name of the current application>",
  "flowId": "<ID of the current workflow>",
  "flowName": "<name of the current workflow>",
  "flowVersion": "<name of the current workflow version>",
  "globals": {}, // object of workflow globals
  "relayId": "<ID of the entity that caused the workflow to fire>",
  "relayType": "<type of entity that caused the workflow to fire>",
  "time": Fri Feb 20 2017 13:23:00 GMT-0500 (EST) // time of the data table action as a Date object
  "triggerId": "<ID of the data table>",
  "triggerType": "dataTable"
}

Bulk Row Insertion

When inserting multiple rows, the new rows themselves are not available on the payload; however, IDs of each added row are included.

{
  "data": {
    "action": "bulkInsert",
    "count": 10, // number of rows that were added
    "errorCount": 1, // number of rows that failed to add as part of the operation
    "rowIds": [ // array of added row IDs
      "<ID of an added row>",
      "<ID of another added row>"
    ]
  },
  ... other default payload properties (see above)
}

Row Update

When updating a row, the row’s old column values and new column values are both included on the payload.

{
  "data": {
    "action": "update",
    "newRow": {
      "createdAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST) // Date object for when the row was created
      "id": "<ID of the updated row>",
      "updatedAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST), // Date object for the update, which matches the "time" property
      ...keys and new values for each column in the row
    },
    "oldRow": {
      "createdAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST) // Date object for when the row was created
      "id": "<ID of the updated row>",
      "updatedAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST), // Date object for the last time the row was updated
      ...keys and old values for each column in the row
    }
  },
  ... other default payload properties (see above)
}

Row Deletion

When deleting a row, the previous row values are included in the initial payload.

{
  "data": {
    "action": "delete",
    "oldRow": {
      "createdAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST) // Date object for when the row was created
      "id": "<ID of the updated row>",
      "updatedAt": Fri Feb 20 2017 13:23:00 GMT-0500 (EST), // Date object for the last time the row was updated
      ...keys and values for each column in the deleted row
    }
  },
  ... other default payload properties (see above)
}

Was this page helpful?


Still looking for help? You can also search the Losant Forums or submit your question there.