I'm trying to programatically set the colour of an Epic on create. I'm using a Scriptrunner Post Function on the create transition
import com.atlassian.jira.component.ComponentAccessor
if(issue.issueType.name == "Epic")
{
final customFieldName = "Epic Colour"
final newValue = "ghx-label-5"
def customFieldManager = ComponentAccessor.customFieldManager
def customField = customFieldManager.getCustomFieldObjects(issue).find { it.name == customFieldName }
assert customField: "Could not find custom field with name $customFieldName"
log.warn(issue.getCustomFieldValue(customField))
issue.setCustomFieldValue(customField, newValue)
log.warn(issue.getCustomFieldValue(customField))
}
It's logging (2nd log.warn) that the field value has changed, but the colour doesn't update and when I check the field value in the UI, it's unchanged.
I tried it on other transitions and adjusted the order of the post-function.
If you add the field "Epic Colour" to an edit screen, it displays and allows you to change the "ghx-label-xx" to another value.