Hi,
I am trying to create a custom listener in where the field "Create Date & Time" is updated when an issue is commented on. The field should update to the date the issue was created on.
The reason for the listener is older issues were this fields needs to be updated.
The script is as follows but it does not seem to work:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.Issue
def customFieldManager = ComponentAccessor.customFieldManager
def issue = event.issue
def cfValues = customFieldManager.getCustomFieldObjects(issue).findByName("Created Date & Time")
cfValues['Created Date & Time'] = issue.created
log.warn(issue.created)
Log Error:
2022-03-09 12:35:32,088 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2022-03-09 12:35:32,088 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null groovy.lang.MissingPropertyException: No such property: Created Date & Time for class: com.atlassian.jira.issue.fields.ImmutableCustomField at Script2015.run(Script2015.groovy:10)