Hi
So, I have created a scripted custom field called "in progress date" which capture the last date the issue was "in progress" status but wipe that field when the status change to any other state other than "in progress" and I could do that successfully using the below code :
package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
def logg = Logger.getLogger("")
logg.setLevel(Level.DEBUG)
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def createdTime = ''
def createdtime = ''
def created = changeHistoryManager.getChangeItemsForField(issue, "status").reverse().findResult{
it.toString == "In Progress" || it.toString == "In Development" ? createdTime = it.getCreated().getTime() : "no date for in progress status" }
//logg.debug( created )
//logg.debug( createdTime )
createdTime ? new Date(createdTime) : null
but now I need the date to not be wiped when the status is changed from in progress to Done in addition to the other condition which is (wipe that field when the status change to any other state other than "in progress")
meaning that wipe the last "in progress date" when the status change to any other state other than "in progress" except when the status changes from in progress to Done
So how Can I achieve that ?
Update : I have figured out a way and it is in the first comment
// capture "first in progress date" and "last in development date" and keep these dates on all other statuses except for "Backlog" and "Ready for Dev"
-------------------------------------------
package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
def logg = Logger.getLogger("")
logg.setLevel(Level.DEBUG)
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def createdTime = ''
//def l = changeHistoryManager.getChangeItemsForField(issue, "status").reverse().first()
def firstprogcreated = changeHistoryManager.getChangeItemsForField(issue, "status").find{
it.toString == "In Progress" }
def progcreated = changeHistoryManager.getChangeItemsForField(issue, "status").last().find{
it.toString == "In Progress" }
def lastdevcreated = changeHistoryManager.getChangeItemsForField(issue, "status").reverse().find{
it.toString == "In Development" }
def devcreated = changeHistoryManager.getChangeItemsForField(issue, "status").reverse().first().find{
it.toString == "In Development" }
def with = changeHistoryManager.getChangeItemsForField(issue, "status").reverse().first().find{
it.toString == "Requires Design" || it.toString == "In Design"|| it.toString == "With Source" || it.toString == "Blocked" || it.toString == "Done" || it.toString == "Cancelled" || it.toString == "In UAT" }
def other = changeHistoryManager.getChangeItemsForField(issue, "status").reverse().first().find{
it.toString == "Backlog" || it.toString == "Ready for Dev" }
switch( true )
{
case { !(firstprogcreated == null ) && (progcreated || with ) }:
createdTime = firstprogcreated.getCreated().getTime();
logg.debug( "progcreated " + createdTime );
break;
case { !(lastdevcreated == null ) && (devcreated || with ) }:
createdTime = lastdevcreated.getCreated().getTime();
logg.debug( "devcreated" )
break;
case { (other) }:
createdTime = '';
logg.debug( "other " + createdTime );
break;
}
//logg.debug( progcreated )
//logg.debug( devcreated )
//logg.debug( l )
//logg.debug( "devcreated2 " + createdTimee )
createdTime ? new Date(createdTime) : null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.