Is there a way to add a transition to send back to the previous workflow status?

Miguel Rodriguez
Contributor
January 16, 2023

We have a transition from ->All to Info Needed status. It means in any other status (to do, backlog, in progress, testing, etc) a user can click on Info needed and assign the task issue to someone else asking for some information needed to continue work. So when that other person provides the info, I want the issue to go back to the previous status where it was before info needed. How can I achieve this? via automation? 
note I am just project administrator, not instance admin, using Jira Software Data center. 
Thanks

4 answers

1 accepted

2 votes
Answer accepted
Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 16, 2023

Hi @Miguel Rodriguez 

It is possibly natively, but you will need an Instance Admin to help set this up (only for Step 1).

This process will work as follows:

  1. Use a Custom Field to list the Status ID of the Previous Status
  2. Use Automation Rule 1 to populate the Custom Field
  3. Use Automation Rule 2 to reverse the transition

See below for instructions on how to do this

---

Custom Field

You'll need to create a Custom Field, which requires Jira Admin (i.e Instance Admin access). Then...

  • Go to Jira Administration > Issues
  • Select Custom Fields from the left-hand menu
  • Press the Add custom field button
  • Create a "Text Field (single line) custom field - for this example, I've called it PreviousStatus

Note: The field does not need to be on a Screen

---

Automation Rule 1

The second Automation Rule will transition to the previous Status, based on the value in the Custom Field above.

Automation Rule 1 will populate this field every time any Issue is transitioned - the rule will look like this:

  • Trigger: Issue Transiitoned
  • Action: Edit Issue
    • Field = PreviousStatus
      • Value = {{#changelog.status}}{{from}}{{/}}

Note: This rule uses a smart value, to reference the Status that the Issue was transitioned from when this rule was triggered

---

Automation Rule 2

We can now reference the previous Status in this Automation Rule - for example:

  • Trigger: Field Value Changed
    • Field = <Field Here>
  • Condition: Issue Fields Condition
    • Field = <Field Here>
    • Condition = equals
    • Value = <Value Here>
  • Action: Transition Issue
    • To Status = {{issue.PreviousStatus}}

Notes:

  • Smart values are used again - this time to reference the Status ID stored in the PreviousStatus field, which was populated in the first rule
  • You can add whatever Trigger and Conditions that are relevant to your scenario - above are just examples

---

Let us know if this is helpful!

Ste

Marcelo Ignacio Cid Abud
Contributor
January 17, 2023

Hi @Ste Wright 

 

Can you display the automation ? (screenshot)

Miguel Rodriguez
Contributor
January 17, 2023

Thanks Stephen, I will keep this one in mind but it seems the suggestion from Mark is a straightforward  out of the box post function. 

Like Ste Wright likes this
Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2023

No worries @Miguel Rodriguez 

The other recommendation is definitely simpler and I would recommend using it if it is available to you.

But it is from an App rather than native functionality; specifically this App: Jira Misc Workflow Extensions (JMWE) 

---

FYI @Marcelo Ignacio Cid Abud - the rule is detailed above; providing screenshots for each screen would be cumbersome.

Ste

Miguel Rodriguez
Contributor
January 18, 2023

@Stephen Wright _Elabor8 good point, I did not realize yesterday that Mark's solution required an additional app.  

Like Ste Wright likes this
Miguel Rodriguez
Contributor
January 19, 2023

@Ste Wright So to understand correctly I have couple of questions:

In the first rule, then the transition goes from any previous status to my target status, we save the previous status to the custom field, right? That is OK. However, on the second rule you posted above. you have this:

  • Trigger: Field Value Changed
    • Field = <Field Here>

So are you expecting that the user changes other field? In my workflow the issue is sent to a Need info status, the person providing the info will add a comment and the idea is to send it back to the previous status when she clicks on Info Provided as part of the workflow buttons. I am not changing the custom field in any screen, so I would expect the trigger of the 2nd rule to be the transition out of my current (Info needed status), so then I would read the custom field value and apply it to where I want to transition to (the original status before sending it to info needed)
Can you clarify the behaviour of the second rule and  how are you reading the previous status from the custom field?
I pasted the workflow below. So for example if I am in Testing and do Info Needed, once I transition out of Info needed I want to go back to testing , with the automation I am getting an error: "No transitions to specified status could be found for issues (with current status):

TEST-768 (To Do - 10000)" so do I need to have transitions to from to do to everything? it does not make sense. 
 workflow1.png
Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 20, 2023

Hi @Miguel Rodriguez 

I made some assumptions about what the Triggers, etc would be - but this is still just an example. You can set the Trigger in Rule 2 to be anything you like.

Although I'd probably recommend it isn't a "Transition Issue" Trigger - that seems counterproductive. For example, it could be based on the Comment itself, as long as it is from a specific user (Reporter, etc).

---

In terms of transitioning to the previous Status - yes, it needs to be possible to go directly from Info Needed to any relevant Status. If the transition is not possible, the Automation will fail. 

Your current Workflow would not support what you're looking to do using the Automation Rule above - you'd need multiple IF/ELSE Conditions, and multiple transitions to get back to "Testing" (for example).

I'd strongly recommend making all Statuses "All" for transitions, if this is an option.

---

If you'd like more specific instructions, can you let us know...

  • The exact process these Issues would go through?
  • If making the Workflow more open is an option?

Ste

Like Miguel Rodriguez likes this
Miguel Rodriguez
Contributor
January 20, 2023

Hello @Ste Wright thanks very much.  Based on the error I was getting, I assumed what you confirmed, I need a valid transition to get to the original status, but I would not like all to all because there are some cases where we want to have a sequence of events, specially for some other more complex workflows. I am going to look at them and see if there is  compromise between a bit of controlled sequence and a flexible return to previous status can be done. Thanks for all your help and clarifications Stephen. 

Like Ste Wright likes this
İsmail Özçelik October 4, 2023

Hi @Ste Wright , your solution works well.

Like Ste Wright likes this
2 votes
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 16, 2023
Miguel Rodriguez
Contributor
January 17, 2023

Thanks a lot Mark, that is exactly what I was looking for. :-) 

Like Mark Segall likes this
0 votes
carlosmestanza
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 9, 2024

Hi, this is my automation and dont work for me. Please can you tell me what im doing wrong?

Captura de pantalla 2024-09-09 170147.png

 

Thanks

0 votes
Asela Jasinghe March 5, 2024

Hi Miguel Rodriguez

The easiest way to do this is using {{changelog.status.from}}  You do not need any custom fields. I have Jira Cloud and it works perfectly.

Example   

image.png

Asela Jasinghe March 5, 2024

 {{changelog.status.fromString}} will give you the actual status in text. However, you can't use it for transition. It will give you error "Destination status could not be resolved. If using a smart-value ensure this resolves to a numeric status ID or untranslated name for issues (with current status):

You have to use the number of the status and it comes from "FROM".  Try adding an action  to comment on issue {{changelog.status}}  it will show all the available values

Example 

ChangeItemBean{fieldId='status', field='status', fieldType='null', from='13961', fromString='In Requirements', to='11200', toString='Blocked'}

In this case "In Requirements" status = 13961 and that's the value it will derive from  {{changelog.status.from}}

 

Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 15, 2024

This works for me based on a transition issue trigger - but not on a field being modified.

Does it work for you using the Field Value Changed trigger?

Ste

Asela Jasinghe March 16, 2024

No, This will have information only when the status is changed. In your case, the only option I can think of is to store the previous status in a custom field when the status is changed and use it when your field is changed. 

Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 16, 2024

Yes that's what I thought - that's why I went with that solution above.

Still an awesome option for Issue Transitioned trigger though :)

Ste

Suggest an answer

Log in or Sign up to answer