Is it possible to get transition dates using script runner?

I need to get the date of certain transitions in certain issues. We are currently manually going into each issue to get the dates.

1 answer

This widget could not be displayed.

Hey Robert 

When you say certain issues I suppose issues that you can get from a JQL ?

Also you say the date of certain transitions does this means the first time that the issues got into that transition ?

 

Hi Thanos,

Yes we run some JQL to export our SLA data, but we manually add a column for transition dates and we get these by manually going into each call. This is basically so we know when the SLA starts.

Example...

trans date.jpg

Hey Robert, 

So what about using a scripted field that will show you the date of first transition, and then since you will have this value in a field you will be able to export it in the same way as any other field. 

How does this sound ?

Where do i declare what issuetype we are reporting?

(eg. issuetype=BILL01 and status=Review)

Sorry about this but im a beginner to this. Thanks

Which version of ScriptRunner you use ? 

If you are in one of the latest versions there is already a canned scripted field Date of First Transition.

Unfortunately we are only using version 4.3.19, but we are doing an upgrade next year. Finally!

Hey Robert, 

No worries. So you have to create the scripted field manually. It is easy. So go to the scripted fields section and add a new one. 

The script for this should be

import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def created = changeHistoryManager.getChangeItemsForField(issue, "status").find {
it.toString == "In Progress"
}?.getCreated()

def createdTime = created?.getTime()

createdTime ? new Date(createdTime) : null

And the configuration should be 

Searcher: Date Time Range picker
Template: Date Time Picker

In the end your scripted field should look like

Screen Shot 2017-11-21 at 15.02.20.pngAnd then you can start using it as any other custom field. 

Please let me know how this went.

Regards, Thanos

The field created with the correct data! Cheers Thanos!

Would i need to create a new one for every transition an SLA starts on? For example we have 3 SLAs on one workflows which all start on different statutes.

Do i need to log that as another question?

Hey Robert, 

No it's all right, I just missed the reply. Can you please give me an example or use case for your second question ?

Regards, Thanos

The users are running a report about SLAs which captures the usual, but they want the start date of the SLA (hence creating the script field), but some issues have more than one SLA, so does this mean have a different script field for each status (start of SLA).

I hope that makes sense?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 13, 2018 in Jira Service Desk

Jira Service Desk – Don’t be afraid, the journey begins with curiosity!

...be more productive while being fun to use at the same time. For some, getting started can be a bit intimidating. This is especially true if Jira Service Desk is your first exposure to Atlassian...

9,340 views 9 28
Read article

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