I just spent about an hour crafting a detailed message about what I need to do, but when I submitted it, I got an error and my message was wiped out. So I'm just going to give the bare essentials here and hopefully someone can help.
I need to know what the status of an issue was before the transition post functions are executed.
I need to skip a step in the workflow under certain conditions, so I'm using the "Fast Track Transition an issue" script, which must be placed after the fire event function.
However, by that point, the issue's original status has been changed by the "linked status of the destination workflow step", and "issue.getStatus().name" returns the new status, not the original status.
Is there a function call that I can use to access the original status?
No luck. Admittedly I'm just trying things and don't understand the difference between using the status?.name vs getStatus().name, tho in the end all of these return the status that I'm transitioning to, not the status the issue was in before the transition was initiated:
The only way I've found yet to get the "previous" status is by putting a post function in as the very 1st step, before the "Set issue status to the linked status of the destination workflow step." But the Fast-track transition specifically says to put it after the "Fire Event" function, so maybe the best I can do it so store off the original Status in Step 1, and then access it in my custom script after the Fire Event?
Ah yes. That rings a bell. There are other community posts that talk about using transientVards instead. Perhaps something here helps? https://jamieechlin.atlassian.net/wiki/display/GRV/Miscellaneous+Groovy+Scripts
I tried a bunch of things keying off that article, but they all also give me back the destination workflow.
Just for completeness, and in case anyone searching wants to see, I tried all of the following:
def myStep = transientVars["createdStep"] as Step def myStepId = myStep.getStepId() def prevStatus = ComponentAccessor.getConstantsManager().getStatus(myStepId as String) log.debug "In fast track, prevStatus.name is " + prevStatus.name log.debug "In fast track, prevStatus.id is " + prevStatus.id int actionId = transientVars.get("actionId") log.debug("The current transition id is: " + actionId) import com.atlassian.jira.component.ComponentAccessor def workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issue) def wfd = workflow.getDescriptor() def actionName = wfd.getAction(transientVars["actionId"] as int).getName() log.debug("Current action name: $actionName")
And got the following debug output, where 4 is the Step for Ready To Build and 31 is the transition for Ready to Build... ;)
In fast track, prevStatus.id is 4 The current transition id is: 31 Current action name: Ready to Build In fast track, originalIssue.status?.name is Ready To Build
Maybe someday I'll figure out an elegant way to do it, but at this point I'm just going to store off the original status off in a variable at the beginning of the Post Function, and then compare it in the Fast Track Post Function.
Thanks for your help!
Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs