Hi,
I want to be able to fast track an issue to a specific transition based on the previous status of the issue.
Example:
The issue can be put 'On Hold' from multiple statuses
My current idea is to use the 'Fast-track transition an issue' built in script but I am not sure of the condition.
I think I would need to create a post function for each possibility (i.e On Hold --> In Progress, On Hold --> Scheduled etc) and check if the previous status was 'In Progress' for example.
I think I would need to somehow check the change history of the current issue, this is where I am coming unstuck!
Any help with my current approach would be much appreciated or other solutions to achieve the same goal.
Thanks
You can get the history items (changeItem) like this
changeItems = componentManager.changeHistoryManager.getAllChangeItems(issue)
Now you can sort this list and search for the last status change and the corresponding fromValue of the changeItem.
Henning
2013-04-08 12:57:46,253 http-bio-8080-exec-32 INFO mikewells 777x15194x1 18qi3hf 192.168.201.187 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.PostFunction] Starting establishing correct status to transition to
2013-04-08 12:57:46,255 http-bio-8080-exec-32 DEBUG mikewells 777x15194x1 18qi3hf 192.168.201.187 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.PostFunction] Previous Status is 'Open': true
2013-04-08 12:57:46,362 Thread-635 ERROR mikewells 777x15194x1 18qi3hf 192.168.201.187 /secure/CommentAssignIssue.jspa [groovy.canned.utils.WorkflowUtils] Errors: {}
Error Messages: [It seems that you have tried to perform a workflow operation (Approve) that is not valid for the current state of this issue (J12345-82). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]
2013-04-08 12:57:46,362 Thread-635 ERROR mikewells 777x15194x1 18qi3hf 192.168.201.187 /secure/CommentAssignIssue.jspa [groovy.canned.utils.WorkflowUtils] Not attmpting transition
Any ideas why this could be happening?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is what I have so far...
import com.atlassian.jira.ComponentManager import org.apache.log4j.Category def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") log.setLevel(org.apache.log4j.Level.DEBUG) log.info("Starting establishing correct status to transition to") def componentManager = ComponentManager.getInstance() def changeHistoryManager = componentManager.getChangeHistoryManager() log.debug("Previous Status is 'Open': "+changeHistoryManager.getChangeItemsForField(issue, "status").getAt(changeHistoryManager.getChangeItemsForField(issue, "status").size() - 2).getFromString().equals("Open")) changeHistoryManager.getChangeItemsForField(issue, "status").getAt(changeHistoryManager.getChangeItemsForField(issue, "status").size() - 2).getFromString().equals("Open")
So line 11 is the condition, I get the second to last item from the change history (I am running this condition after the issue has effectivly transitioned back to 'On Hold' so I need to take that extra history in to consideration)
I then run the 'Approve' transtion, this has a pre-condition that only a user in project role "Project Manager" can execute the transition. I am in that role so the permissions should be good.
I get this in my log output...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Scratch that last question, the issue was that the transition I was calling wasn't available in the status. So I reworked the workflow a little and now it works. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.