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
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
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

327 views 0 6
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