Hi everyone
I am trying to enter the below code into a "Script listener" and I seem to be caught in a loop here I seem to be facing one of two error messages no matter what I do.
"Event undeclared" or "Issue undeclared"
Any Help anyone could gibe would be great and thank you in advance.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.field.CustomFieldUpdatedEvent
def issue = event.issue as Issue
def response_string = new URL("URL for my API").text
def slurper = new groovy.json.JsonSlurper()
def resultString = slurper.parseText(response_string)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def custom_field = customFieldManager.getCustomFieldObjectByName("My single select field")
def fieldConfig = custom_field.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'resultString'}
issue.setCustomFieldValue(custom_field, value)
Join our 3-part live learning series with community leader Robert Hean to master how to leverage Confluence for Marketing teams. Learn how to plan and execute on projects seamlessly and how to turn insights into lasting organizational knowledge. 🧠
Register today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.