Script runner validator not working

any ideas how to correct this:

/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [c.o.jira.behaviours.GroovyScriptLoader] Class or file does not exist at this location

/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Class or file does not exist at this location
java.lang.Exception: Class or file does not exist at this location

This is the script it is occuring from:

import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.component.ComponentAccessor

def cfm = ComponentAccessor.getCustomFieldManager()
Issue myIssue = issue

def verFixedField = cfm.getCustomFieldObject("customfield_19712") // Version Fixed field
def verifySteps
def steps

def selVer = myIssue.getCustomFieldValue(verFixedField)

if (myIssue.IssueType != 'Story' && myIssue.IssueType != 'Story-task') {

	verifySteps = cfm.getCustomFieldObject("customfield_19511") // Steps to Verify field
	steps = myIssue.getCustomFieldValue(verifySteps)
}

def rtrnResult = true
def verChk = false

if (selVer ==~  /^\[\d{1,3}\.\d{1,2}\.\d{1,2}\.\d{1,3}\]$/) {	
        verChk = true
}

if (myIssue.IssueType != 'Story' && myIssue.IssueType != 'Story-task') {
    if ((myIssue.getResolution() == "Fixed") && ((verChk == false) || (steps == null))) {
        rtrnResult = false
    }
} 
else
{
    if ((myIssue.getResolution() == "Fixed") && ((verChk == false))) {
        rtrnResult = false
    }	        
}

return rtrnResult

 

 

1 answer

Hi J Starbird, 

When you say a worfklow validator you mean something like Validators right ?

The error message you get look like you are trying to do something with a Behaviour.

I can also see in your script 

// this will fail
myIssue.IssueType

//this is the right way
myIssue.issueType.name

Also a validator, when you want from it to fail, have to return 

throw new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of 'Fixed'")

regards, Thanos

Thank you. 

The error actually went away after I upgraded to the latest version of the plugin. 

I will make the changes you mentioned though.

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

181 views 0 4
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