Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Behaviour static type checking errors

Kevin Berger April 1, 2016

We have installed the Adaptavist ScriptRunner for JIRA plugin. We would like to implement Behaviours Initialisers; however we find that code that we think should work results in static type checking errors. For example, this Behaviour serverside script has issues as it indicates:

"The variable [issue] is undeclared"

Our code is:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def textCf = customFieldManager.getCustomFieldObjectByName("Client")
String clientname = issue.getCustomFieldValue(textCf)

However, this script has no issues when we add a script Post-function (Custom script post-function) to a workflow transition.

Is this expected? Is there something we can do to get this working in a Behaviour Initialiser script?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
adammarkham
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.
April 1, 2016

You need to use "underlyingIssue" instead of "issue" for behaviours: https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#zeroClipboardButton0

So your code should be:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def textCf = customFieldManager.getCustomFieldObjectByName("Client")
String clientName = underlyingIssue.getCustomFieldValue(textCf)
Kevin Berger April 1, 2016

Thanks Adam. That works.

TAGS
AUG Leaders

Atlassian Community Events