Hi,
I want to update a Date custom field by adding 90 days to the value of another date custom field. Say, Date1 is today, I want the Date2 field to have the date 90days from today, updated automatically upon a transition using script runner. Below is the script I used, the script ran successfully, but the field value didn't get updated in the ticket. I'm not sure what I have missed. Could you please help me with this.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// the dependent custom field
def dateACF = customFieldManager.getCustomFieldObjectByName('Date1')
def dateB = customFieldManager.getCustomFieldObjectByName("Date2")
// get the value of the date A custom field
def dateAValue = issue.getCustomFieldValue(dateACF) as Date
// If the date field is empty ignore it
if (dateAValue==null) {
return null
}
// build the new date
dateB = Calendar.getInstance()
// copy to the new date the value of the Date A custom field
dateB.setTime(dateAValue)
dateB.add(Calendar.MONTH, 3)
return dateB.getTime()