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?
Community moderators have prevented the ability to post new answers.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.