On Value/Item Change
On Value Change
Parameter
On Value Change
is a JavaScript expression that is executed any time value of the field is changed. You can use it to reference any input fields, including Field Groups. For Field Groups, the expression is executed when the value of any of the nested fields is changed. For Repeatable Field groups, the expression is executed when new items are added or removed and when any of the nested fields within any item are changed. In addition to the standard Field Execution Context variables, On Value Change
has one more:
Name | Type | Description |
---|---|---|
|
| Previous value of the field. Type of the value depends on the field type |
On Item Change
On Item Change
expression is available for Repeatable Field Groups and allows tracking changes of a particular item. model.getIndex()
can be used within On Item Change
expression to get the index of a changed item.
Updating Starting Point data within On Value Change
You must delay any updates performed from On Value Change
to startingPointData
and model
using a 0ms $timeout
. Because $timeout
is not available in Field Execution Context, you must create a utility function in one of the Wizard-level onLoad actions:
Wizard On-load Action:
if ($scope.dspSession == undefined) {
$scope.dspSession = {}
}
$scope.dspSession.handleMyValueUpdate = function (value, oldValue) {
$timeout(function () {
var time = (new Date()).toLocaleDateString()
$scope.addStartingPointData(
'LastUpdate',
oldValue + '-' + value + ' (' + time + ')'
)
})
}
On Value Change expression:
dspSession.handleMyValueUpdate(value, oldValue)
Example
wizardState.lastChange = oldValue + ' -> ' + value