state-machine rules and oldValue() and becomes() functions
Hi everyone!
I will try to get the old value of the issue field State when State changes from one to other:
transitions: {
'testEnvInstall': {
targetState: 'testEnvInstall',
action: function(ctx){
console.log(ctx.issue.fields.State.oldValue());
}
},
// TODO: define other transitions from the initial values
}
but I got exception:
org.mozilla.javascript.JavaScriptException: Invalid argument: undefined
but why? Perhaps because the state marked as:
initial: true
and the whole history of the State become empty?
Please sign in to leave a comment.
The syntax is incorrect. In JS-based API you need another instruction to access the old value:
ctx.issue.fields.oldValue(ctx.State)
As `ctx.issue.fields["Field name"]` represents the value of the field in the current issue, it can be `undefined`, so there is no sense to have `oldValue()` function of the value itself.