Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

capture "first in progress date" and keep this date all other statuses except for 2 statuses Edited

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

 

1 answer

1 accepted

0 votes
Answer accepted

// 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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Introducing External Collaboration for Confluence

We’re excited to introduce external collaboration for Confluence, now available in early access. It is available to preview for Confluence Cloud Premium and Enterprise customers. (If you're not on ...

197 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you