You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!

3

Change the Value of a Custom field in a Post Function

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.

Requirements

  • Jira Jira (8.0 - 8.14)
  • ScriptRunner for Jira ScriptRunner for Jira (6.18.0)
    
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)
Discovered an issue? Report it here

Suggested for you

Appears in these Collections