Trying to hide the "Create Subtask" UI element based on a Single Select Custom Field value (CMR Type equals Normal"). I have tried using Script Runner UI Fragments > Hide system or plugin UI element but it is not working as expected.
Am I missing something in this script? The "Create Sub-task" disappeared completely irrespective of any value in CMR Type field.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def issue = ComponentAccessor.getIssueManager().getIssueObject(issue.id)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("CMR Type")
if (customField) {
def customFieldValue = issue.getCustomFieldValue(customField)
log.debug("Custom Field Value: ${customFieldValue}")
return customFieldValue == 'Normal'
} else {
log.warn("Custom field not found: Your Custom Field Name")
return false
}