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.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.