Groovy Script doesn't work JIRA 7

Sam Morris February 12, 2016

Since upgrading to JIRA 7 my script on Scriptrunner to update a check box is no longer working.

The script finds the checkbox with it's existing values and adds a new value. 

def checkbox_cf = customFieldManager.getCustomFieldObjects(parent).find {it.name == 'BI Deployed to Environment'}
def new_value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'UAT' }
def current_options = parent.getCustomFieldValue(checkbox_cf);

checkbox_cf.updateValue(null,parent,new
 ModifiedValue(parent.getCustomFieldValue(checkbox_cf), 
current_options + [new_value]),changeHolder);


The error is occurring on 

current_options + [uat_value]

Can anyone help?

6 answers

1 accepted

0 votes
Answer accepted
Sam Morris February 14, 2016

Thanks guys the answers is - 

def customFieldManager = ComponentAccessor.getCustomFieldManager()

 

 

0 votes
arno schumacher February 13, 2016

Try

def customFieldManager = ComponentAccessor.customFieldManager

or

def customFieldManager = ComponentAccessor.getCustomFieldManager()

 

0 votes
Hung Nguyen February 12, 2016

I believe the customFieldManager must be gotten by a function instead

def customFieldManager = ComponentManager.getInstance().getCustomFieldManager()

0 votes
Sam Morris February 12, 2016

I declare the customfieldManager like this - 
 

def MutableIssue parent = (MutableIssue) issue.getParentObject();

ComponentManager componentManager = ComponentManager.getInstance();
def customFieldManager = ComponentAccessor.CustomFieldManager
def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class)
def changeHolder = new DefaultIssueChangeHolder();

0 votes
Sam Morris February 12, 2016

I'm getting this error in the logs -

groovy.lang.MissingPropertyException: No such property: CustomFieldManager for class: com.atlassian.jira.component.ComponentAccessor
Possible solutions: customFieldManager

 

0 votes
Chander Inguva
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.
February 12, 2016

Hi Sam,

              Did you turn on debugging and check what log file says ?

Suggest an answer

Log in or Sign up to answer