Forums

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

How to populate END date automatically

Musku Nagaraju
Contributor
May 18, 2020

Hi Team,

I am trying to populate a Date field by Adding days to another date field value.

Consider, there are two date fields "Start Date" & "End Date" and a numeric field "Number Field" for days.

Required Output : End Date = Start Date+NumberField

 How can I achieve this with the groovy script?

I used the below code but getting below error, Please help me on this.

Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def daysToAddCF = customFieldManager.getCustomFieldObjectByName("Duration")
def dateACF = customFieldManager.getCustomFieldObjectByName("StartDate")

def dateAValue = issue.getCustomFieldValue(dateACF) as Date
def daysToAdd = issue.getCustomFieldValue(daysToAddCF) as int
def EndDate = Calendar.getInstance()

EndDate.setTime(dateAValue)
EndDate.add(Calendar.DATE, daysToAdd)
return EndDate.getTime()

 

Capture.PNG

1 answer

0 votes
John Funk
Community Champion
May 18, 2020

Hi Musku,

I am not familiar with Groovy, but it can easily be done with an Automation For Jira rule. 

Musku Nagaraju
Contributor
May 18, 2020

Hi John,

Thanks for you quick respond, yes, but I am looking to get this fields should be populate automatically in create screen like End Date = Startdate=Duration .

With help of automation we can get that field create automatically once issue has been created.

 

Thanks

Nagaraju

Suggest an answer

Log in or Sign up to answer