Getting current issue in scriptrunner listener static error

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2022

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
C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 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. 

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2022

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