Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,360,313
Community Members
 
Community Events
168
Community Groups

Scriptrunner error on time duration/counter Scripted Field

Hi, how can I resolve the following?

running JIRA 6.4.7 and Scriptrunner 4.1.3.5

 

import com.atlassian.core.util.DateUtils
def resolvedNames = ["Resolved", "Closed"]
def timeDiff;
if (issue.statusObject.name in resolvedNames) {
    timeDiff = issue.getResolutionDate().getTime() - issue.getCreated().getTime()
} else {
    timeDiff = System.currentTimeMillis() - issue.getCreated().getTime()
}
DateUtils.getDurationString(Math.round(timeDiff / 1000))

 

Error -

 

image2015-12-10 12:5:49.png

 

1 answer

1 accepted

0 votes
Answer accepted
JamieA Rising Star Dec 10, 2015

You can probably just do a cast there:

DateUtils.getDurationString(Math.round((timeDiff / 1000) as Double))

Not exactly sure what's going on, but it's obviously having trouble inferring the type for "timeDiff / 1000".

It's safe to ignore the type checking information... https://scriptrunner.adaptavist.com/latest/jira/#_static_type_checking

Thanks Jamie. That worked a treat!

Suggest an answer

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

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

192 views 1 6
Read article

Atlassian Community Events