Hello,
I have done this with a regular issue type, but for some reason the same script will not work when I define a subtask instead. my two use cases below:
1.)When a defect issue type reaches closed, update the defect closure date/time to the date/time the status was updated to closed. This script works:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import java.sql.Timestamp
def issue = event.issue as Issue
def issuetype = issue.getIssueType()
def statusObj = issue.getStatus()
def simpStatus = statusObj.getSimpleStatus()
def statusName = simpStatus.getName()
if (issuetype.getName() == "Testing Defect")
if (statusName == "Closed") {
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Defect Closure Date")
def changeHolder = new DefaultIssueChangeHolder()
def now = new Timestamp(new Date().getTime())
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), now),changeHolder)
}
2.) When a Deployment Request subtask issue type reaches Ready for Technical Verification status, update the Implementation Date/Time to the date/time the status was updated to Ready for Technical Verification. This script does not work:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import java.sql.Timestamp
def issue = event.issue as Issue
def issuetype = issue.getIssueType()
def statusObj = issue.getStatus()
def simpStatus = statusObj.getSimpleStatus()
def statusName = simpStatus.getName()
if (issuetype.getName() == "Deployment Request")
if (statusName == "Ready for Technical Verification") {
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Implementation Date/Time")
def changeHolder = new DefaultIssueChangeHolder()
def now = new Timestamp(new Date().getTime())
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), now),changeHolder)
}
I am guessing it has to do with defining the subtasks/issue type, but I have no failures and the script logs reference the test issue key, but doesnt update the field. Any ideas?