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
AUG Leaders

Atlassian Community Events