Groovy Post function on Create transition can't set custom field


We have recently upgraded to JIRA v 8.11.0

Our aim is to create a new Workflow which will create a new JIRA and set the Values of some Custom Fields.

The Workflow does:

  • Creates the issue
  • Re-index an issue to keep indexes in sync with the database.
  • Fire a Issue Created event that can be processed by the listeners.
  • Run the groovy script below

However, the existing Custom Fields are not getting updated

Can someone give me a hint why I am not able to set the values of Custom Fields of newly created Issues even if the custom script runs after the issue is created ?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import org.apache.log4j.Category

// ComponentManager has been deprecated since JIRA 7.11

log = Category.getInstance(“com.onresolve.jira.groovy”)
log.debug “start debugging ASS-1482”

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder()
Issue issue = issue

def allCustomfields = customFieldManager.getCustomFieldObjects(issue)
def count = 0
def i=0
log.debug “–”+allCustomfields[i].getFieldName()+"–"
log.debug “finished display customfields”

def opsKycField = customFieldManager.getCustomFieldObjects(issue).find { == ‘OPS-KYC analyst’}
opsKycField.updateValue(null, issue, new ModifiedValue("", “SB36AU”), changeHolder)
log.debug "PR ID now set to: " +issue.getCustomFieldValue(opsKycField)

Additionally, nothing appears in the log file.

Test of ASS-1482

2020-09-15 11:29:34,249+0200 http-nio-8080-exec-15 INFO SB36AU 689x72783x1 pvctuf /secure/admin/ViewLogging!markLogs.jspa [c.a.j.util.log.LogMarker]

Test of ASS-1482 end