Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Post Function Condition Based on Time in Certain Status

Cole
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 25, 2019

I am trying to create a groovy script post function or condition that only lets a transition happen if the issue has been in that status for at least 30 days. Also, this would only apply for issues when a cascading select list is a certain value.

I figured I could probably use the "Scripted (Groovy) Condition (JMWE add-on)" option to accomplish this.

 

Basically, if cascading select = Colorado - Denver then this transition can only be triggered if it has been in the In Progress status for at least 30 days. Otherwise, it must stay in that status.

1 answer

1 accepted

0 votes
Answer accepted
Cole
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 25, 2019

I came up with this:

import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def items = changeHistoryManager.getChangeItemsForField (issue, "status").reverse()
def time
def source

source = issue.get("customfield_16401")?.get("1")?.value

if (source == "Denver") {
time = ((new Date().time - items.first().created.time) / 1000) as Long
}
else {
time = 2592000
}

if (time >= 2592000) {
return true;
}
else {
return false;
}

I'm not sure if this is the best way to do it, but it seems to work. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events