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
I suspect by "Environment field", you mean the system Environment field, not a custom field.
The system field is text, so you don't need the .getName(), but also the field belongs to issues, not request types. So I don't know what you're intending to do with a request type here.
The value of the environment field in a scripted field is just (from memory)
return issue.getEnvironment()
Hi Nic,
Correct, Environment field as in the system Environment field not a custom field, we are setting it through an automation rule based on the field request-channel-type or a set of other conditions but it itself is the system Environment field.
I'm not wanting to do anything with a request type, I just want to copy the text in the Environment field to a custom field, let's call it Environment-scripted, so that it can be queried in our reporting tool, the current system field, Environment, isn't available.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am accepting @Nic Brough -Adaptavist- answer because oddly enough, the only code I needed in the scripted field was he provided -
issue.getEnvironment()
Making something so simply, complicated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.