Forums

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

How to update the date custom field based on date value of the other custom date field?

swapna_r
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 5, 2020

I have two custom date field:

Incident Reported Date and Target REQ Completion Date.

I have to update Target REQ Completion Date 3 weeks ahead based on the date selected in Incident Reported Date.

Script:

import com.atlassian.jira.component.ComponentAccessor
import java.sql.Date
import java.sql.Timestamp
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue


def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("issuekey")
def IncidentReportDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Incident Reported Date")
def REQCompletionDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Target REQ Completion Date")

Timestamp csDate1Value = (Timestamp) issue.getCustomFieldValue(IncidentReportDate)
Date csNewDateValue = new Date(csDate1Value.getTime() + 21*24*60*60*1000);
REQCompletionDate.updateValue(null, issue, new ModifiedValue("", (Object) csNewDateValue), new DefaultIssueChangeHolder())

 

But this script not working.

Can anyone help with this.

Thanks in advance,

Swapna

0 answers

Suggest an answer

Log in or Sign up to answer