I have a script that updates the custom field value of developer to match the issue assignee on all issue events and it works great.
I am trying to write a script that does something similar, but its not working (its also not failing, it just shows its not running at all) and I'm not sure which part I have wrong.
I am trying to update the custom field value of the field "cc date replacement" (12828) with the value of the custom field "cc date" (10522)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def issue = (MutableIssue) event.issue
def cc = ComponentAccessor.customFieldManager.getCustomFieldObject(10255) // "CC Date"
def datetimePickerField = ComponentAccessor.customFieldManager.getCustomFieldObject(12828) // "CC Date (Replacement)"
// Set the CC Date Replacement Field to be the same as CC Date
issue.setCustomFieldValue(datetimePickerField, issue.cc)
ComponentAccessor.issueManager.updateIssue(cc, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
here is the script that I based it off of that is working which updates the custom field of "developer" with the value of the issue assignee.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def issue = (MutableIssue) event.issue
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def userPickerField = ComponentAccessor.customFieldManager.getCustomFieldObject(10553) // Developer
// Set the User Picker to be the same as Assignee
issue.setCustomFieldValue(userPickerField, issue.assignee)
ComponentAccessor.issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)