Scriptrunner - set a calculated date

Domi March 20, 2020

Hello colleagues

I'm trying to set a date in the field "Last working day", which is 3 months after the creation date of the issue. The field remains blank and the log of the script shows the creation date. Not the value I expected. what am I doing wrong in the calculation, and in setting the value in the date field?

I use Scriptrunner in a post function.

 

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

def csDate2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Last working day")

Timestamp csDate1Value = (Timestamp) issue.getCreated()
Date csNewDateValue = new Date(csDate1Value.getTime() + 90*24*60*60*1000);
// the date field expects a Timespamp
log.warn("Logging:" + csNewDateValue.toTimestamp() )
issue.setCustomFieldValue(csDate2, csNewDateValue.toTimestamp())

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events