Reputation: 6848
There are different states in our task like: open, in-progress, fixed, tested, closed. We need to design a workflow to prevent users from closing an opened task.
I went through the documentation an saw codes like this:
var user;
if (issue.Assignee == null) {
user = issue.project.leader;
} else {
user = issue.Assignee;
}
The problem is that codes like above just check for statuses. I need a way to prevent actions (like closing an open task). How should I prevent users from such actions? How to check if he is closing the task?
In the documentation it's been mentioned how to access issue fields and issue custom fields. But again the code looks like below:
if (issue.State == Open) {
# what to do here how to check if he is closing the task?
}
How should I check he is closing the task? What should I do to tell the user you cannot close the open task?
Upvotes: 0
Views: 339
Reputation: 6848
After a lot of working with the code I found the solution:
rule check open state
when issue.State.becomes({Open}) {
assert issue.State.oldValue == {Submitted}: "Issue needs to be in Submitted state, to make it Open"
}
I had to use becomes
in order to check whether user is opening the task, and then by using assert I'd make sure if the task is changed from Submitted
state to open or not.
Upvotes: 0
Reputation: 2116
Upvotes: 1