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

This widget could not be displayed.

Thanks guys the answers is - 

def customFieldManager = ComponentAccessor.getCustomFieldManager()

 

 

This widget could not be displayed.

Hi Sam,

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

This widget could not be displayed.

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

 

This widget could not be displayed.

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

This widget could not be displayed.

I believe the customFieldManager must be gotten by a function instead

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

This widget could not be displayed.

Try

def customFieldManager = ComponentAccessor.customFieldManager

or

def customFieldManager = ComponentAccessor.getCustomFieldManager()

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

294 views 1 4
Join discussion

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