Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to resolve class com.okapya.jira.customfields.ChecklistItem

Dawid Zielinski
December 19, 2017

So I have this code in a Scripted Field:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.okapya.jira.customfields.ChecklistItem
@WithPlugin("com.okapya.jira.checklist")

def isReady(checklist) {
def uncheckedExists = false
def uncheckedRequiredExists = false

for (checklistCondition in checklist) {
def checklistItem = ((ChecklistItem) checklistCondition)
if (!checklistItem.isChecked()) {
uncheckedExists = true
if (checklistItem.isMandatory()) {
uncheckedRequiredExists = true
break
}
}
}

if (uncheckedRequiredExists) {
return "Not-Ready"
} else if (uncheckedExists) {
return "Required-Ready"
} else {
return "Fully-Ready"
}
}

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def fieldDoR = customFieldManager.getCustomFieldObject("customfield_14004")
def checklistDoR = fieldDoR.getValue(issue)

return isReady(checklistDoR)

Sometimes it works and sometimes it doesn't.

JIRA (Data Center - 2 nodes) version: v7.3.3#73014
ScriptRunner version: 5.2.2

Please help :)

3 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 5, 2017

Hello.

I have set up a test environment and it seems to work. I have attached this customlistener to every issue event. As you can see here:

 

correctaccess.png

Could you tell us which event you are attaching the listener to so that we are able to give it a try?

 

Cheers!

Ron Gates
Contributor
April 5, 2017

Thank you for testing!

The Custom Listener I have defined triggers on "Issue Resolved" event.

Jira that I am testing this on is v7.3.0.

Maybe there is a problem with that specific version of Jira - what version are you using?

Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 5, 2017

Hi Ron.

Glad to run some testing for you. We checked out different jira versions, 7.3.0, and 7.3.3 and in both cases it worked. We realized that in your issue, we see that in the original question, you have:

 

def issueKey = "JIRA-1234";

 

however, you say it does not work when:

 

def issueObject = issueManager.getIssueObject("KEY-1234")

We've noticed that the two keys are different. Could this be the cause of your issue? 

 

 

Ron Gates
Contributor
April 5, 2017

Thanks for some more testing!

I am glad this works in general and causing problem only for me.

I use actual project key from our Jira instance - the "JIRA-1234" and "KEY-1234" are just examples.

Problem still persists for me but I have a workaround (I shared it in the initial post - so I'm good).

Also this hopefully won't be a problem soon as we migrate to different Jira instance (and I hope this problem will disappear).

2 votes
Dante Labate
May 24, 2018

It works!

def issueKey = "JIRA-1234";
def issueManager = ComponentAccessor.getIssueManager()
def issueObject = issueManager.getIssueObject("${issueKey}")

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 4, 2017

It looks like it doesn't think it's a string.

Ron Gates
Contributor
April 4, 2017

Official Jira docs says it needs to be a String:

https://docs.atlassian.com/jira/server/com/atlassian/jira/issue/IssueManager.html#getIssueObject-java.lang.String-

But even after explicitly specifying type of the variable or converting it to string the error persist.

Go figure...

TAGS
AUG Leaders

Atlassian Community Events