onTableChanged

What it does

This event enables a remote system like Acumatica to call into Jigx and trigger changes on a mobile device by monitoring data updates. It detects changes in specific data tables (entities) and executes the configured actions accordingly. A common use case is ensuring data consistency between the remote system and the app and keeping information updated across the system.

How it works

External system data changes

  1. The remote system pushes data changes to the Jigx endpoint.

  2. The Jigx endpoint stores and continuously syncs the data to a Dynamic Data table.

  3. The onTableChanged event monitors the Dynamic Data table for updates.

  4. When a change is detected, the event triggers an action that updates the mobile app.

Internal local data changes

  1. When data is saved to a local table on the device, the onTableChanged event monitors the table for changes.

  2. Upon detecting a change, the event triggers the configured action to sync the data with a Dynamic Data or remote table.

Where and how to configure it

  1. In the Jigx API endpoint configuration, specify a name for the remote system's data table. This is the name given to the Dynamic Data table.

  2. In default.jigx, add the Dynamic Data table name.

  3. In index.jigx, add the onTableChanged event property at the root level.

  4. Specify the data table the event should monitor for changes—this should match the table defined in the Jigx endpoint and default.jigx.

  5. Configure an action (e.g., action.sync-entities) to execute when a change is detected.

  6. Use IntelliSense to select from the list of available actions.

Considerations

Key factors to keep in mind when using this event.

  • Multiple onTableChanged events can be configured in the index.jigx file.

  • The event continuously listens for data changes on the specified table.

  • It can be used with any data provider, including local, REST, SQL, and Dynamic Data.

  • The event can listen for changes in one table and respond by updating another table using the actions property.

  • In the SQL data provider, when using the functionCall method, the onTableChanged event does not execute because the data changes occur directly on the backend and do not affect local data.

  • When the app is in the background, and changes occur in backend remote data tables, the onTableChanged event executes once when the app opens to apply the data changes. This ensures optimal app performance and prevents multiple redundant executions.

  • When the app is open and data changes are made, the event executes individually for each detected change.

  • Avoid creating a loop in onTableChanged by checking a table for changes and then modifying the same table.

Examples and code snippets

Single data table

This example demonstrates how to use the onTableChanged event to monitor data changes in a single table from a remote data system. When a data change occurs on the remote system, the event executes and resets the solutions state.

Multiple data tables

This example demonstrates how to use the onTableChanged event to monitor data changes across multiple tables and different data providers within the solution. When a data change occurs, the event executes the defined actions for each configured data provider.

In the second table, multiple actions are configured, including action.sync-entities, which is dynamically updated by specifying a list of entities, functions, and function parameters using an expression. This is particularly useful when the number of entities to sync and their corresponding parameters are not always known.

Action data changes from one table to another table

In the example below, the send-notifications table is monitored for changes. Once notifications are sent, the event executes and updates the customer table with the relevant data.

Last updated

Was this helpful?