Automated transition based on PREVIOUS status

We have created a custom workflow, with custom statuses to represent 2 different 'work groups':

1) 'At Support' (issue is with the Support 'work group')
2) 'At Tech Support' (issue is with the Tech Support 'work group')

Both of the above statuses can transition to the status 'At Reporter'.

When the 'Reporter' comments, we want the issue to transition back to the most recent status just before that.

I tried adding this to the IF condition:

"status changed from "At Tech Support" TO "At Reporter".

That gets me 80% of the way. The problem is that the above query catches any issue that EVER underwent that transition. I want to catch just those issues where the MOST RECENT transition was "At Tech Support" TO "At Reporter".

Can anyone think of an elegant approach for this?

2 answers

I implemented a solution to a problem very similar to yours.  Not sure if one can classify it as elegant, but it works.  Here's what I did...

In my case, when the issue is in the Waiting For Customer (WFC) state, and the Reporter comments, the workflow transitions back to Waiting For Support (WFS).  However, what I want the workflow to do is transition to the state the issue was in before it transitioned to WFC.  How do I know the state previous to WFC?  I store the state in a custom field.  Let's say the custom field is preState.  The custom field is not visible on any screen.

So, in the transition Respond to support, which is the transition that takes the issue from WFC to WFS, I have a post function that transitions the issue to the previous state saved in the custom field preState.  The post function I execute is Transition issue.  It's available in the JIRA Misc Workflow Extensions add-on.  When configuring the Transition issue post function, there are two fields to fill in.  1) A transition to execute, and 2) a condition.  I'll finish my answer w/ specifics.

Let's assume that one possible state that my issue can be in before transitioning to WFC is Accepted.  Then I what I did is added a Transition issue post-function to my Respond to support transition so that I automatically go back to the Accepted state if Accepted was the state previous to WFC.  To configure the Transition issue post function, I specified Accept for the Transition field and the following code for the condition.

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;

CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();

CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "preState" );

String preWFCstate = issueObject.getCustomFieldValue(customField_name);

return true;
return false;


Please consult the attached image of my workflow.  So sorry for the really lengthy answer.  Hope it helps.

IMPORTANT NOTE: In my implementation, the Accept transition from WFS to Accepted cannot have a screen.  Otherwise the Transition issue post function from WFS to Accepted will not work.


Hi Juan

Many thanks for your detailed feedback (and my apologies for the delayed response).

I came to a similar conclusion myself, before I saw your answer.

I use a hidden field, but without a custom plug-in - just using the 'automated rules' builder in SD 2.4.1.

Each time a relevant transition takes place, I use a post function to store the previous status in the hidden field. (I think that part is common to your approach.)

Then, in the automated rules section, I check for the 'previous status' before deciding which transition to invoke.


PS: Not as elegant, as I wanted, but it works...



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 13, 2019 in Jira Service Desk

What's new in Jira Service Desk Server: Introducing 4.0 & more - Feb 2019

Hello Atlassian Community!  I'm Teresa, the Product Marketing Manager   for Jira Service Desk Server at Atlassian. I'm excited to announce two exciting releases for Jira Service De...

363 views 1 1
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you