Automation for Jira: Transition to previous state

spe July 5, 2018

Hello

I in our workflow we have the status "Wait". When we transition to the status we set a "Wait until" date.
Once that date's been reached the automation rule executes and notifies the assignee via e-mail about the waiting period being over.

The "Wait" status can be reached from various other statuses but can always only go back to the previous one and itself.

Now we want the issue to automatically transition back to the status it came from,
(Like, if it comes from "Planning" it can only go back there.)


I already tried it with smart values from the Advanced fields documentation but that didn't work.

Specifically I tried using the value below. But it always gives me an error in the audit log that the transition needs a numerical status id.

{{#changelog.status}}{{from}}{{/}}

Is there any other way to solve this?

 

Thanks in advance.

7 answers

2 accepted

3 votes
Answer accepted
andreas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2018

Hi Sebastian,

Yes we don't really support this very well yet (see https://codebarrel.atlassian.net/browse/AUT-47).

For now the best option would be to record the previous status id in a custom field as @Christopher Jaksch mentioned.

You could use a rule like this:

  • Trigger: Field value changed with status
  • Edit issue and set the 'Previous status' field to  {{fieldChange.from}}

Then you could transition to {{issue.Previous status}} using the 'Transition action'.

We'll hopefully make this easier in future, but we've got quite a few higher priority items in our backlog currently.

Cheers,
Andreas

spe July 6, 2018

@Christopher Jaksch/ @andreas

Thanks you two.

That solution worked. :)

Derek Mart November 15, 2018

How was this accomplished?  I'm not sure what "transition action" means. Where do I place "{{issue.Previous status}}"?

Derek Mart November 15, 2018

I'm using Automation Lite for JIRA.

Derek Mart November 15, 2018

Figured it out. Disregard.

Peter Reiser
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2020

Hi Derk 

How did you do:

 I'm not sure what "transition action" means. Where do I place "{{issue.Previous status}}"?

 

I can't figured it out yet :-(

Jan Stähle January 25, 2021

Dear @Derek Mart - How can I specify {{issue.Previous status}} in the Transition Action? - All I get is copy or the statuses available but no free expression field.
Thanks,
Jan

Jan Stähle January 25, 2021

Nevermind @Derek Mart - Figured it out. Thanks for your solution. 

Michael Spoonauer April 5, 2021

Can anyone think of why I would get a 5-digit code for {{fieldChange.from}} for status instead of its actual two-digit code?

abioye_bankole
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!
April 22, 2021

@Peter Reiser @Derek Mart @Jan Stähle I also see the Transaction Action but don't know where to specify {{issue.Previous status}}.  Kindly advise possibly with a screenshot.  Thanks!

abioye_bankole
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!
April 22, 2021

Figured it out.  Never mind.  Lol.

For anyone who's losing time figuring it out, paste {{issue.Previous status}} into the dropdown field for the statuses.  It then gets recognised as a smart value.  Yes, it's not intuitive enough and took some trial and error to get it.

Like # people like this
Raphael Henrique Fernandes Lopes January 3, 2022

I don't understand this.

Can u help me?

Raphael Henrique Fernandes Lopes January 4, 2022

help me pleaaaase.

Bartosz Mazurek January 20, 2022

I have an issue with this approach as well, when I want to save previous status on transition, the field doesn't get updated.

Zrzut ekranu 2022-01-20 o 12.11.32.png

 

What should be the edit issue smart value in this case?

Bartosz Mazurek January 20, 2022

Ok, i found the problem.

For some reason Issue Transitioned trigger doesn't work with this - you'll have to use Field Changed for Status field - then everything works great.

Boriz Agustin January 25, 2022

I followed the steps as suggested but it doesn't seem to work for me.

My goal is, for every tickets with a status of "Cancelled", if anyone creates a comment on the ticket, the ticket will automatically reopen and transition to the previous status it was from.

Can you help me determine what I'm doing wrong?

Cancelled.JPGng?




Bartosz Mazurek January 25, 2022

@Boriz Agustin Can you please share your audit log for this automation?

 

Also please try this: Remove Edit issue fields node you have here, and create a separate automation to save the previous status into custom field. Something like this:

Zrzut ekranu 2022-01-26 o 07.45.32.png

 

And then just use your current automation to change and transition the issue, just without saving the previous status bit in the same automation.

Boriz Agustin January 27, 2022

Hello @Bartosz Mazurek thank you for the assist. I tried what you suggested but still it did not work.

I have created a separate rule that defines the value of Previous status through Project automation. See below:

Previous Status.JPG

And modified the original Automation:

CST Audit Log.JPG

 

Same issue occurs, the status still remains the same.

Bartosz Mazurek January 27, 2022

@Boriz Agustin It looks like the issue is that automation cannot resolve the status its supposed to transition the issue from your custom field. What did you setup your custom Previous Status field as? 

I have it set as Text Field (single line), can you check/confirm this?

Boriz Agustin January 27, 2022

@Bartosz Mazurek I have it set as Text Field (single line), I also added the Project as a context.

Bartosz Mazurek January 27, 2022

@Boriz Agustin Can you show how does your previous status field looks like? I mean what exactly gets written there.

Boriz Agustin January 27, 2022

@Bartosz Mazurek  I have this on:

Previous Status.JPG

 

Thank you in advance!

Bartosz Mazurek January 27, 2022

@Boriz Agustin I meant the actual data that gets stored in the field. You can for example showcase the Previous Status on issue screen, so we can see actually what gets written there for each issue.

Boriz Agustin January 27, 2022

@Bartosz Mazurek Oh OK, sorry about that. The automation seems to blank out the field. I tested this by putting an initial value to the "Previous Status" field during create.

Bartosz Mazurek January 27, 2022

@Boriz Agustin I think if you fix that to make sure that the field always contains correct status ID, whole thing should work correctly.

Boriz Agustin January 27, 2022

Hi @Bartosz Mazurek , yeah, that's the exact problem I'm having. I'm using "Allow all statuses to transition to this one" on the Cancelled status so setting the value on post-function is not really an option. Any ideas on what else to check on why it doesn't get populated?

Bartosz Mazurek January 27, 2022

@Boriz Agustin Try using the automation for saving previous status as I shared in one of previous screenshots, where it gets triggered on every transition by using When: Value changes for: Status. I think that should work correctly.

Boriz Agustin January 27, 2022

Thank you @Bartosz Mazurek , I believe that will work but the triggers available for me is limited and does not allow to target specific field change.

P.S. I was able to make this work using the {{#changelog.status}}{{from}}{{/}} and {{issue.Previous status}}

Theodore Copeland
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!
August 11, 2022

Thanks all! I was able to get this to work by using "Re-fetch issue data" between the When clause and the Transition.

Selection_481.png

2 votes
Answer accepted
Christopher Jaksch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2018

Hi @spe,

as a workaround you could define a new custom field "previous status" where you enter the "string" of previous status automatically via post function.

You could use this information for your automatic rule to go back from "wait" to the previous status.

Hope that helps

Best wishes
Chris
STAGIL

1 vote
Lewis Cook September 15, 2022

Just jumping in on this as I have had similar issues as many on this thread!

So first off "{{fieldChange.from}}" didn't work for me. Like many others I found that "{{#changelog.status}}{{fromString}}{{/}}" was working to set the Previous Status field to what appears to be the name of the Status.

However it appears that it's setting it to a "Status - Status ID" value which when you attempt to use it in the other rule Automation doesn't like.

So I ended up using "{{#changelog.Status}}{{from}}{{/}}".

My rules that are working for peoples context:

SetPreviousStatus Rule.pngTransition to previous status rule.png

0 votes
Kevin Dickson April 30, 2024

Hi Community,

Just been reading through this chain of threads, and wondering how this is possible when the initial poster said: "..The "Wait" status can be reached from various other statuses but can always only go back to the previous one and itself..."

Unless there is a transition back to the previous state in the workflow, how is this possible?

Lewis Cook April 30, 2024

They never shared a workflow so I guess we can assume one of the following:

  1. It's a very messy workflow with transitions enabled to all other applicable statuses from the "Wait" status presumably with some validation that would limit your target options back to "Wait" or the previous status
  2. They've used a lot of "All" transitions on their statuses and put in conditions to limit the target options based on previous status
  3. It's not a technically enforced process just an agreement of how to handle it (seems least likely).

From working on other similar automation rules it will error if it's unable to find/resolve the target destination status. Either because there isn't a transition or the "previous status" field has become stale/outdated.

Where I've implemented similar there a few sections of the workflow where I didn't technically want it to transition to the previous status, so I put in workflow post functions (or automation rules) to set the previous status field to the desired Status ID I would want it returned to.

Like Kevin Dickson likes this
Kevin Dickson April 30, 2024

Post functions sounds like a great idea, I'll look into that.

0 votes
Steven Camilleri May 15, 2023

image.png

image (1).png

Hi, I hope this helps someone! I saw a lot of people doing multiple rules. I have managed to do it in a single rule! It works as expected.

0 votes
Xheneta G. Hyseni May 6, 2022

Hi all,

Can maybe someone provide a screenshot how the automation worked at your end, which trigger do you use? 

My goal similar to yours: Move an Issue from "Blocked" Status to the previous one. 

Thanks and Best,
Xheneta

Bartosz Mazurek May 6, 2022

Hey @Xheneta G. Hyseni ,

this is what works for me:

Here I am saving the previous status to a custom field:

Zrzut ekranu 2022-05-6 o 13.01.08.png

Zrzut ekranu 2022-05-6 o 13.00.41.png

 

And here, in separate automation, I am changing the status to a previous one. Just the transition issue is necessary to move it, all the remaining steps are for my case when I want this to happen.

Zrzut ekranu 2022-05-6 o 13.02.02.png

Like Xheneta G. Hyseni likes this
Xheneta G. Hyseni May 9, 2022

Hi @Bartosz Mazurek

Thanks a lot, I will give this a try.

Best,
Xhen

0 votes
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2018

Hello @spe

If documentation is correct, it should work.

I would advise you to raise request to Automation support, because i didnt see many codebarrel guys on community :)

And you can try some workarounds, like create branched rule, that will checks prevous status 

{{#changelog.status}}{{fromString}}{{/}}

and do direct transition based on status.

spe July 5, 2018

Hello @Mark Markov

I tried that, too. Unfortunately it doesn't work. In the audit log it always says that the issue doesn't match the compare condition...

I'll try the Automation support then.

Thanks.

sergio.peschiera May 19, 2022

{{issue.Previous status}} did not work for me. I'm getting an error when using the smart value as seen below. Can you please advise what I'm doing wrong?

image.pngimage.png

Like Xheneta G. Hyseni likes this
Tristan August 5, 2022

Had the same issue, it is now working after typing instead of pasting the smart variable {{issue.Previous status}} in the transition action.

sergio.peschiera August 12, 2022

works now, thanks

Aslıhan Paksoy February 2, 2023

Hi @Tristan , can you show the details? Because I have tried your suggestion but it didn't work and I am kinda desperate.

Thanx

Suggest an answer

Log in or Sign up to answer