Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Auto transition based on custom field value

Raj Kumar January 21, 2019

We have a end date custom field we mention a end date during creating a issue, when it reaches automatically a transition should happen from Status A to Status B.

Thanks,
Raj

3 answers

1 accepted

0 votes
Answer accepted
Ravi Varma
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.
January 21, 2019

Hi @Raj Kumar,

If you can explore custom development as an option, then you can write a scheduler which wakes up and scans the JIRA issues (You can limit the scheduler processing to a specific project and specific status, based on your requirement) and execute the transitions/ change the status.

Regards,

Ravi Varma

Beppe Marcon July 2, 2019

In the mean time between the scheduler waking up and the field being updated the ticket would be in an inconsistent state. Not the most elegant solution imho.

Ravi Varma
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, 2019

Hi @Beppe Marcon ,

The scheduler can be run every 1 minute or 30 seconds.

Unless, all the created issues have the same end date, accurate till the 1 minute/30 seconds, which is highly unlikely, the scheduler should be processing few issues whenever it is triggered. 

Changing the status for less number of issues, should not take much time. 

If JIRA has performance issue due to high usage, I agree with your statement that the scheduler approach would have some latency, which is a known and accepted risk for any automated solution.

Regards,

Ravi Varma

0 votes
Alexey Matveev
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.
January 21, 2019

Hello,

You would need an add-on for it.

For example, you could use the Power Scripts add-on:

https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview

With this add-on you could create a job, which is run by schedule. In this job you would select all issues with expired end date and auto transition such issues.

Your code would be like this:

string jql;

jql = "'End Date' < now()";

string[] keys = selectIssues(jql);

for (k in keys) {

  autoTransition("Transition Name", k);

}

You can find how to create a schdule job here:

https://confluence.cprime.io/pages/viewpage.action?pageId=6558186

Beppe Marcon July 2, 2019

The job would need to run very often and still there would be times of inconsistency before the job is called. Not very scalable and pretty dangerous imho.

valterj
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!
February 21, 2020

just define k and make autoTransition non-camel and you're good to go:

string jql;
string k;


jql = "'End Date' < now()";

string[] keys = selectIssues(jql);

for (k in keys) {

  autotransition("Transition Name", k);
0 votes
Mario Carabelli
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.
January 21, 2019
You could create a scripted field in Scriptrunner for Jira which at execution (every time the issue is updated or viewed) compares the current time (you get this one with a groovy/java method) with the value of the end date field.
Then you can an specify with the internal jira api the transition of the issue your scripted field is placed on.
If you or a colleague have some scripting experience this shouldn't be to hard to realize.
With kind regards
Mario
Beppe Marcon July 2, 2019

You could but it would not work consistently. The reason is the event is triggered the moment the issue is being updated but is not finalized yet, the transition would try to transition the issue and find it in an inconsistent state and fail.

Apparently Jira cannot trigger transition based on field value update event. 

Suggest an answer

Log in or Sign up to answer