I have 3 Datetime Picker custom fields:
- Date1
- Date2
- Date3
I would like to initialize Date2 based on Date1 + 1 day and Date3 based on Date1 + 15 days.
I also need to block modification of Date2 and Date3 except by people defined in a group.
How can I do that with JIRA v6.1.5#6160-sha1:a61a0fc ?
I tried with ScriptRunner and the following code :
import com.atlassian.jira.issue
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import java.text
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dateMEP = customFieldManager.getCustomFieldObjectByName("Date MEP") // Date time fields require a Timestamp
def dateDG = customFieldManager.getCustomFieldObjectByName("Date début garantie") // Date time fields require a Timestamp
def dateFG = customFieldManager.getCustomFieldObjectByName("Date fin garantie") // Date time fields require a Timestamp
def df = new DateFormat()
issue.setCustomFieldValue(dateDG, new Timestamp((new Date(df.parse(dateMEP)) + 1).time))
issue.setCustomFieldValue(dateFG, new Timestamp((new Date(df.parse(dateMEP)) + 15).time))
Am I on the right way or does it exist another method ?