I've been unable to find information on how exactly to copy the Environment field to a scripted text field that will be available in our reporting tool.
The issue lies in that the Environment field isn't exactly a "custom field type" so def cfType as cf.getCustomFieldType() doesn't work and I don't have a solution.
This is what I have, from using an actual custom field but it won't work for the Environment field, which I am setting using an automation rule based on summary information or request-channel-type.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
def FIELD_NAME = "Environment"
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName(FIELD_NAME)
def cfType = cf.getCustomFieldType()
def requestType = issue.getCustomFieldValue(cf)
I need to modify the code above to work with the system field, Environment and copy the text contents of that field into a custom-field, Environment-scripted