Forums

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

Event or Issue not declared

Gregory Riccardi October 9, 2018

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

Atlassian Community Events