Forums

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

Help me with the script in script runner

ashok 1234
Contributor
May 22, 2018


I need to calculate and display in a dashboard gadget the average time between two custom date fields.
More specifically, in the  project, I want to know the average time (in days) between 'Customer Request Date' and 'Customer Proposal Date'.

1 answer

1 vote
Ojase
Contributor
May 23, 2018

Create scriptrunner scripted field and use the below code on ocnifguration

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import  java.util.Date.*

def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObject('customfield_id1');

def dateFieldObject2= customFieldManager.getCustomFieldObject('customfield_id2');

if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2)) {
def dateValue=  issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2=  issue.getCustomFieldValue(dateFieldObject2) as Date
return dateValue - dateValue2
}
ashok 1234
Contributor
May 23, 2018

Thanks a lot !!!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events