Variable ‘onValueChanged’ Events

Specific to variables, the 'onValueChanged' event is raised by the framework when a variable’s value changes.

To add an event listener to an event, specify it in the 'onValueChanged' property of the variable. Event listeners can only be added to the root variable, not to any sub-objects of the variable structure. It uses the same syntax as other event listeners.

"variables" : {
  "incidentId": {
    "type": "string",
    "input": "fromCaller",
    "required": true,
    "onValueChanged": {
      "chains": [
        {
          "chainId": "fetchIncidentChain",
          "parameters": {
            "incidentId": "{{ $event.value }}"
          }
        }
      ]
    }
  }
},
Old and new variable values are available in the $event implicit object.
  •  $event.oldValue provides the variable’s old value.

  • $event.value provides the variable’s new value.

  • $event.diff can be used for complex types, where it is necessary to know the properties within the variable that changed.

See the Variables section for details on variables.

Optional parameters can be sent to the action chain in response to the event. See the JSON Action Chains section for more information.

Multiple event listeners can be added for the same event (note that 'chains' is an array property). In this case, the event listeners will be run in parallel with respect to each other.