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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,815 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot