import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
//copy object in single-select field onto global Numeric field
def formField = getFieldById(getFieldChanged()) // "Estimated Story Points" field
def storyPointsField = getFieldByName("Story Points") // Numeric Field
def estimatedStoryPointsValue = formField.getValue()
if (estimatedStoryPointsValue) {
try {
// Convert the selected option into a numeric value
def numericValue = estimatedStoryPointsValue.toString().toInteger()
storyPointsField.setFormValue(numericValue)
} catch (Exception e) {
storyPointsField.setError("Invalid selection: Unable to convert to a number.")
}
} else {
storyPointsField.setFormValue(null) // Clear if no value selected
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter