Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Event or Issue not declared

Gregory Riccardi October 9, 2018 edited

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)

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence, confluence for marketers, atlassian community events, ace, confluence training, confluence marketing workflows, atlassian learning, marketing tools, content marketing, marketing pm, atlassian live learning, confluence for teams​

Great marketing starts with Confluence. Join our live learning sessions to learn how! 📹

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!
AUG Leaders

Atlassian Community Events