Scriptrunner Behaviours global declarations in intialiser

Steven Mustari
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.
October 28, 2020

When declaring a variable in a behaviour, is it possible to declare something in the intialiser and reuse it elsewhere in the same behaviour?

For instance, I do a bunch of checks on assigned fields from a list and compares to validate content matches for certain conditioning. I'd like to reuse these fields later in the behaviour without re-declaring everything... is it possible?

An example is something like this:

def cf_ateam = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Assigned Team")
def ateam = underlyingIssue.getCustomFieldValue(cf_ateam) as String
def infTeams = ["Atlassian Administration","Systems Administration","Network Administration","Database Administration"]
def isInfIssue = infTeams.contains(ateam)

 I'd like to reuse this (isInfIssue) later in certain field behaviours. (within the same behaviour if that makes sense)

Thanks!

0 answers

Suggest an answer

Log in or Sign up to answer