Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,294,690
Community Members
 
Community Events
165
Community Groups

Getting current issue in scriptrunner listener static error

Hello

Scriptrunner version 6.49

In my listener I am getting issue like this:

import com.atlassian.jira.issue.Issue;
def thisIssue = event.issue as MutableIssue

I am shown a static error like this

[Static type checking] - No such property: issue for class: com.atlassian.jira.event.AbstractEvent @ line 31, column 96.

 

Can you please let me know what is best way to get current issue in event listener.

 

Thanks

Abe

1 answer

0 votes
Derek Fields Community Leader Jun 02, 2022

Generally, you can ignore the static type checking error. Groovy can't know before run time that the event is an IssueEvent, so it can't determine that there is an issue property. 

BTW - I don't see that error in my version of ScriptRunner. However, if you want to clear up that error, you can do this:

import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.MutableIssue;

def thisIssue = ((IssueEvent)event).getIssue() as MutableIssue

 As a general practice, you are better off using the getter/setter functions than accessing the properties of an object directly. 

I am getting this static error now

[Static type checking]  The variable [event] is undeclared.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you