Forums

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

Can't get issue Object when creating a Automation triggered by issue transition

Jiwei Li
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 7, 2024

I am writing a automation script to access value of a custom field, triggered when there is a certain transition of status on issues.

 

However, seems I just can't get access to the issue object. It is very frustrating, please help.

---- Code---

import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.issue.link.IssueLinkType


println "pwd".execute().text

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10212");// here replace the ID with ID of your custom field.

def value = (String)issue.getCustomFieldValue(customField);

println "$value"

 

-----error -----

Unexpected error executing rule:
groovy.lang.MissingPropertyException: No such property: issue for class: 

I have also tried other ways to get the issue object like:

def issue=event.getIssue() 
Issue issue=issue

I always got the same errors of No such property on issue or event

 

 

1 answer

0 votes
Pauline Hennau April 11, 2024

Hello, to help you I would need more information. Is this code a Listener or a post function ? 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.5.0
TAGS
AUG Leaders

Atlassian Community Events