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?
Thanks!
Anne
Can you access details of the issue prior to the change with originalIssue?(e.g. originalIssue.status?.name)
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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.