how to get 'Time In Source Status' like on Transition Tab?

my jira version is 4.4.1

i want to obtain spent time from Open status to Resolved status,and display the spent time in one custom field.

and find 'Time In Source Status' on Transition Tab is like what i want.

but i don't know how the 'Time In Source Status' comes from ?

7 answers

1 accepted

Accepted Answer
0 votes
Mizan Community Champion Jan 14, 2013

Did you try using scripted fields provided by Script runner plugin ? There is a similar script provided in the docs https://studio.plugins.atlassian.com/wiki/display/GRV/Scripted+Fields#ScriptedFields-TotaltimethisissuehasbeenInProgress

You will need to modify it to suit your requirement , you will need to add one field for each status.

thanks,

i used Scripted Field,below code is used to obtain time spent from first 'Open Status' to 'In Progress Status

import com.atlassian.core.util.DateUtils
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.history.ChangeItemBean
import com.atlassian.jira.issue.Issue 
 
def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()
 
 log.warn("+++++++++++++++++++++++")
def rt = [0]
def createTime=issue.getCreated().getTime() // getTime() tranfer to milliseconds
log.warn("create time:"+issue.getCreated().toString()+"to millisecond:"+issue.getCreated().getTime())
def firstStart=changeHistoryManager.getChangeItemsForField(issue, "status").find{
it.fromString=="Open" && it.toString=="In Progress"
}?.getCreated()

if(firstStart){ //has Start Progress
	Duration=firstStart?.getTime()-createTime
        // NOTE: doesn't show anything if less than 60 seconds
        log.warn("Duration:"+Duration+"round:"+Math.round(Duration / 1000)+"timespent:"+DateUtils.getDurationString(Math.round(Duration / 1000)))
        def timeSpent=DateUtils.getDurationString(Math.round(Duration / 1000))
        if(timeSpent){
                return timeSpent
        }else{ //negative value or less than one minute
                return "less than one minute"
	}
}else{ //there aren't workflow transitions executed yet.
	def timeSpent = System.currentTimeMillis() - createTime
        DateUtils.getDurationString(Math.round(timeSpent/1000))
}

Andrey,

Thank you for your work it is very usefull

Yes, the Issue History Collector aka datacollector worked well for us

Hi Andrey, thanks for this plugin, i see lot of positive feedback on this, can we get this data in filters so that we can create report multiple issues, like status, time in that status, assignee etc. columns in filters, same can be displayed in dash board Appreciate your help and support on this. Thanks Raj

Hi,

There is a Time in Status Plugin on marketplace. You can get reports depending on user, project and advanced mode. You can export the reports to excel also.

Tansu Akdeniz

Andrey

Thank you very much for your work it is very usefull

Andrey,

Thank you for your work it is very usefull

We have a plugin vertygoSLA which captures that information. This is a plugin to monitor and track SLA compliance. This is however not a free plugin but you can try it for free for 30 days.

https://confluence.atlassian.com/display/JIRA/JIRA+as+a+Support+System

Rahul

Transition tab comes from JIRA Suite Utilities. What do you mean by 'you want to use post function'?

i just want to use post function

hi Renjith

i just want ot retrieve the time spent from Open status to Resolved status. and store the spent time in one custom field.

so i consider using post function to obtain the spent time. and store the value in custom field.

i don't want to use script file to run groovy code , but i can not find any place to put my own groovy code.

i find the "Script Post-Function" ,it has 'Built-in-Scripts' and 'Script file path'.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

105 views 4 7
View post

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you