requirement is, when we enter a value in field(date), it should automatically update the next custom field with adding 15 days.
i need a groovy script for this. please advise
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 csDate1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("test_date1")
def csDate2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("test_date2")
Timestamp csDate1Value = (Timestamp) issue.getCustomFieldValue(csDate1)
Date csNewDateValue = new Date(csDate1Value.getTime() + 15*24*60*60*1000);
csDate2.updateValue(null, issue, new ModifiedValue("", (Object) csNewDateValue), new DefaultIssueChangeHolder())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
15 means days if you want 9 days it would be 9*24*60*60*1000
9d*24hh*60mm*60ss*1000
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This worked for me too, after trying loads of other possibilities including the IssueManager/IssueService to send an update... this is the first post that finally helped me set a new value for a date custom field... Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.