Handling data changes in client-side human services
In instance details and task UIs, data can be changed both
locally by the user or remotely by another user or service. The remote
changes must be propagated to the user's browser to keep the data
in the UI current. However, the user might have unsaved changes that
need to be reconciled with incoming server updates. Use a data change
event handler to react to and handle remote data changes.
About this task
For instance UIs, data changes can be to any of the input variables. For task UIs, the changes
are limited to variables that are shared business objects or content objects. A data change event
handler checks for remote changes to the input variables of the client-side human service in the
following ways.
- At regular intervals that are based on the settings for the system timer.
- Explicitly by a user if the data change event handler is bound to a view, for example, Refresh Button.
When changes are detected, the data change event handler
is started, and its subflow is triggered. While the event handler
is running, you can use the tw.system.coachUtils and tw.system.dataChangeUtils JS
APIs to access the local and remote changes. If you want to use data
changes after the data change event handler finishes, for example,
to resolve conflicts between local and remote changes, copy the data
that you need to local variables.
Tip: To reduce memory
consumption in the browser and to provide a better experience for
users, minimize the amount of information that is held by the client.
Therefore, copy only the information that your use case requires.
When the execution of the data event handler finishes, control is returned to the coach that was running when the event handler was started.
Human services for process UIs automatically include a default data change handler.
Note: When client-side human services contain one or more nested client-side human services, only
the root-level data change event handler is used. If the data change event handler in a nested
client-side human service is bound to any view, you can redirect those bindings to the root data
change event handler by selecting Trigger the root data change event handler
in the Implementation properties of the nested client-side human service
activity.
Procedure
The following procedure describes how to add a data change event handler to a human service. If one of the following situations apply, follow all the steps in the procedure:
- You are creating a new data change handler implementation, for example, because you didn't generate the process instance UI from the template.
- You are upgrading a client-side human service from an earlier product version.
to the diagram.