Change the Value of a Custom field in a Post Function - malikovalibek/groovyForJira GitHub Wiki
Overview This script sets the value of a custom field during a workflow transition using a post function.
Example When a customer reports a bug in our support portal, I want the value of the Error Level, custom field to be set to a fixed value. I can set up this post function to automatically set the custom field to "Level 1 Error" after the bus is created.
Good to Know Use 'Text Field' as the custom field type. import com.atlassian.jira.component.ComponentAccessor
// Name of the custom field to change final customFieldName = "TextFieldA"
// New value for that field final newValue = "I love Groovy !"
def customFieldManager = ComponentAccessor.customFieldManager def customField = customFieldManager.getCustomFieldObjects(issue).find { it.name == customFieldName }
assert customField: "Could not find custom field with name $customFieldName"
issue.setCustomFieldValue(customField, newValue)