Auto transition based on custom field

Mike
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 2, 2018

Hi - 

Our Purchase Request workflow needs to be updated so if users leave "None" selected in the "No Approval Required?" custom field, the issue will transition directly to REQUESTED.

Likewise, if something else (NOT None) is selected, the issue would go to APPROVED. 

Currently, when the issue is created, its left at a NEW REQUEST status.

I have not had luck with setting up a 'condition' 'value field' - Do I need to utilize Script Runner? I have tried as well with no luck. Any help is appreciated, thank you.

workflow.PNG

Custom Field:

customfield.PNG

 

3 answers

1 accepted

7 votes
Answer accepted
Joe Kyle
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 2, 2018

Another way to handle this is to create an Automation Rule as mentioned by Aswin above. Within the project, go to Settings - you should then see the dark blue navigation bar on the left. look for "Automation". Click on that. In the upper right, click "Add Rule". choose "Custom Rule" at the top. Click Continue. "When this happens..." choose "Issue Created" click Add.

Then click “Add condition” button. Under “If these match…” click “Issue matches” then click “Advanced”. (it will be a blue hyperlink) In the code box which appears begin typing the name of your custom field. "No Approval Required” and select it once it shows up and hit the space bar once.  Then type the “=” or select it from the drop down that appears. Hit the space bar after the “=” and you should see another drop down and you can select “None”. ("No Approval Required" = "None") Then click Add.  

Then, under “Then do this…” select “Transition Issue” and you should see the option in the drop down for “Requested”

Click Save.

Note this will only work for the project you currently are in. Not for any of the other projects associated with the workflow you have in that project. (if that workflow is shared with other projects). So, you would have to repeat this process for every project where you need this functionality.  To get this to work across multiple projects sharing the same workflow you would have to add a post function to that workflow.

Joe Kyle
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 17, 2018

Thank you Mike! Very glad I could help. Joe

Supriya Jha April 8, 2019

Thank you Joe! Worked like a charm. Why is everyone recommending Script Runner, phew!?! Because of those answers the task seemed more daunting at first than it was.

Shani Kovalsky May 14, 2019

Hi @Jo , I read your answer and I tried to perform the same thing on my project but it didn't work. 

I think the reason is that the custom field value was changed only after the issue was created. 

Is there a way to change status automatically when a value of a custom field is changed, even after the issue was created?

 

Thanks!

1 vote
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 2, 2018

ScriptRunner has built-in script, Fast track transition an issue, that you could use that checks if your custom field has then None value and if true, fast track the issue to Requested.

Mike
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 2, 2018

That's what I have been playing with, I wanted to confirm I was going in the right direction. Thank you.

 

I selected the Project KEY,

  • Events: Issue Created
  • cfValues['No Approval Required?']?.value == 'Batteries'
  • Action Delivered

However, when I create a new issue using Batteries, the status is not changed to Delivered.

0 votes
Aswin Achuthan
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 2, 2018

Jira cannot trigger transition based on the field value. You might need Automation for Jira, ScriptRunner as you mentioned or writing your own custom field with this behavior.

Beppe Marcon July 2, 2019

Script runner custom Event in theory would do this, in practice when the IssueUpdated event is raised the Issue is in an inconsistent state and transitioning it would fail. It seems to be a not well publicized limitation of the current Jira event implementation.

Suggest an answer

Log in or Sign up to answer