Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner Field Duration

Seena Schmitt
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 25, 2022

I'm having two issues with the script below for my scriptfield "Duration"

  1. On a dashboard column, my field "Duration" is showing up in what I assume is seconds (24,001,086 ; 86,000,000 ; etc.). I want it to appear in days
  2. Within the issues themselves, it's displaying as Duration: $DateUtils.formatDurationPretty($value)

I'm very new to scripting, so any help is appreciated

def startedOn
def goLive

def startedOnField = customFieldManager.getCustomFieldObjectsByName('Actual Kickoff Date').getAt(0)
if (issue.getCustomFieldValue(startedOnField))
startedOn = (issue.getCustomFieldValue(startedOnField) as Date).getTime();

def goLiveField = customFieldManager.getCustomFieldObjectsByName("Go Live Date").getAt(0)
if(issue.getCustomFieldValue(goLiveField))
goLive = (issue.getCustomFieldValue(goLiveField) as Date).getTime();

if (startedOn && goLive) {
// Return in Days
return ((goLive - startedOn)/86400).toLong()
}
else {
return 0
}

1 answer

0 votes
Ilya Stekolnikov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2022

may be something like this

((goLive - startedOn)) as Long)/ 1000 as long ?: 0L

Seena Schmitt
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 27, 2022

That didn't seem to work

Suggest an answer

Log in or Sign up to answer