Script runner failure after JIRA update

JIRA: 6.3.12

Script runner: latest

 

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.event.issue.IssueEventDispatcher
import com.opensymphony.workflow.InvalidInputException
bR = (issue.resolution?.id == "6")
passesCondition = true
if (issue.resolution?.id == "6")
{
cfm = componentManager.getCustomFieldManager()
nff = cfm.getCustomFieldObjects(issue).find {it.id == 'customfield_10200'}
cfv = issue.getCustomFieldValue(nff)
if (cfv == null)
{
passesCondition = false
this.invalidInputException = new InvalidInputException("customfield_10200","Defferral Justification field is required when resolving issue as Proposed to defer")
}
}
this.passesCondition=passesCondition
return [:];

 

When the Validator is supposed to work, I get the following:

 

An unknown exception occured executing Validator com.atlassian.jira.workflow.SkippableValidator@47141bd3: root cause: No such property: componentManager for class: vl_defer

 

Please advise. 

3 answers

1 accepted

1 vote

I don't know, maybe I removed componentManager from the binding as it's deprecated. The quick fix is to add 

import com.atlassian.jira.component.ComponentAccessor

and replace 

cfm = componentManager.getCustomFieldManager()

with

cfm = ComponentAccessor.getCustomFieldManager()

Thanks, but the validator it not working as it used to work. It simply does nothing. As if it does not exist.

Thank you for your answer, Jamie Echlin.

The error is gone. But the validator does not work any more. It's meant to work this way: do not allow resolve with 'Propose to Defer' resolution if the customfield_10200 is empty.

It worked in JIRA6.2. 


What can go wrong? Maybe there is another way to check it? 

I don't understand this: this.passesCondition=passesCondition return [:]; Just do: return passesCondition

Thank you, Jamie Echlin.

 

It works now, I updated the plugin and introduced your code fix suggestions. 

 

Thanks for such a great support. 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

387 views 1 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