Scriptrunner behavior doesn't appear to execute

Robin Barfield August 24, 2020

I have a custom field set up but I only want it to be writable if the Reporter is either an administrator or a service desk agent else it should only be readable.   It appears that my script does not execute at all.   I have added logging messages and we can't find them in any logs.   I have also tried taking out my condition to just set the field as read only and that didn't work either.   My Behavior Settings are as follows:

1.  It's associated to the proper screen in my project

2.  Not using validator plugin

3.  Guide workflow: none

4. No initialiser function

5.  Correct field is selected and option for 'ReadOnly' is checked.

 

I'm expecting the script to get the reporter and check to see if the reporter is in the Administrator or Agent groups and if so then make the field writable

 

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import org.apache.log4j.Logger
import org.apache.log4j.Level

def mylog = Logger.getLogger("com.onresolve.jira.groovy")
mylog.setLevel(Level.DEBUG)

mylog.warn("L5 : begin behavior script " )

def Reporter = getFieldByName("Reporter")
def ActualDateOverride = getFieldByName("Actual First Response Date Pick Date")

def groupManager = ComponentAccessor.getGroupManager()
def Administrators = groupManager.getGroup("jira-administrators")
def Agents = groupManager.getGroup("jira-servicedesk-users")

mylog.warn("L5 : Reporter = " + Reporter)
mylog.warn("L5 : Administrators = " + Administrators)
mylog.warn("L5 : Agents = " + Agents)

if ((Reporter in Administrators) || (Reporter in Agents))
{
mylog.warn("L5 : Setting read value to false = " )
ActualDateOverride.setReadOnly(false)
}

mylog.warn("L5 : end behavior script " )

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events