Conditional state machine transition in JS Workflow
Answered
Is there an equivalent to the [always] for JS workflow ?
Maybe something like
transitions: {
'Open this issue': {
targetState: 'Open',
conditions: {
'Issue is reported': {
checkFunction: function(ctx){
return ctx.issue.isReported;
},
errorMessage: 'The issue must be reported to be open'
},
'another condition': {
// ...
}
}
}
}
Please sign in to leave a comment.
Hello, thank you for reaching out!
I've created a feature request following your question: https://youtrack.jetbrains.com/issue/JT-41547 Please feel free to vote/comment on it.
In the meantime I can recommend to use the `if` constructions.
Please let me know if you have any questions, I'll be happy to answer.
Hi, thank you for creating the feature request.
I don't really see what you are talking about the `if` constructions. How can they be used here ?
Would you mind elaborating on this a bit?
In case you want a piece of code that would be called on any issue change, creating an onChange rule will do the trick.
If you what some logic executed when an issue is in a certain state, then you can declare a property of a state called onEnter. For more details see the documentation: https://www.jetbrains.com/help/youtrack/standalone/2017.2/v1-Issue.html (the stateMachine section).
Grecko,
Basically you can put all the conditions you need inside `if`s or `check`s (previously `assert`s):
I want to conditionally disable some state transitions in a state machine workflow.
I could have a workaround and do that in the `onEnter` function of the target state with an assert, but that's not exactly the same behaviour. I might want to have different conditions based on the source state.
This is also related to https://youtrack.jetbrains.com/issue/JT-12684 if that one get implemented one day.
Thank you Mariya for pointing me to `action`, I wasn't able to find it in the documentation.
This kinda resolves my issue, even though waiting for a transition to throw an error when trying to execute it rather than preventing its execution beforehand feels dirty.
I also feel like having a condition property (maybe just a single function not an array of objects like I suggested) is necessary if you ever want to implement JT-12684.
Thank you all for your help, I guess this is now more a feature suggestion than an actual problem ;)
Thank you, I've marked the request that was created based on this thread as a duplicate of JT-12684.