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

0 votes
Accepted answer

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
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,381 views 15 19
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