Hello,
I have a Groovy script that assigns the project lead for an issue to the "Approvers" multi-user picker custom field in JIRA service desk. This script runs in the "Create issue" transition post functions.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
projectLead = issue.getProjectObject().getProjectLead().getKey()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField customFieldApprovers = customFieldManager.getCustomFieldObjectByName( "Approvers" );
issue.setCustomFieldValue(customFieldApprovers, projectLead)
log.debug(issue.getCustomFieldValue(customFieldApprovers).toString())
The debug output of this script successfully outputs the project lead as if it had been assigned to the "Approvers" custom field, but when I check the custom field after creating an issue, it is blank. If I comment out the issue.setCustomFieldValue method, it outputs "null" if there is no value in the "Approvers" custom field and the username as expected, when testing this on issues that I have created and manually assigned a value to the "Approvers" custom field.
What can I be doing wrong here? I've tried moving the scriptrunner to different positions in the post functions list but that doesn't seem to have any effect, and based on the debug output it looks like the script is working, except it's not.