Groovy Script doesn't work JIRA 7

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

Thanks guys the answers is - 

def customFieldManager = ComponentAccessor.getCustomFieldManager()

 

 

Hi Sam,

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

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

 

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();

I believe the customFieldManager must be gotten by a function instead

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

Try

def customFieldManager = ComponentAccessor.customFieldManager

or

def customFieldManager = ComponentAccessor.getCustomFieldManager()

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

775 views 3 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you