Groovy Script error: No signature of method com.innovalog.jmwe.IssueProxy.getResolution()

kevinbushman March 6, 2017

I'm working on updating this script but am running into the following error if i try to use this as part of my resolve screen. Any tips on how to debug it? 

Image 133.png

import com.opensymphony.workflow.InvalidInputException;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager;
import com.atlassian.jira.issue.fields.layout.field.FieldConfigurationScheme;


def report_error(String field, String message) {
    if (! invalidInputException) {
        invalidInputException = new InvalidInputException("The fields marked below must be filled for issues with resolution of \"${issue.getResolution().getName()}\"")
    }
    invalidInputException.addError(field, message)
}

def requiredResolution = issue.getResolution().getName() in ['Fixed', 'Done', 'Resolved']

//Issue Type Variables
def isADefect = issue.issueType.name == "Defect"
def notAnEpic = issue.issueType.name != "Epic"
def notAtask = issue.issueType.name != "Task"
def notASubtask = ! (issue.issueType.name in ['Development', 'Story Defect', 'Sub-task'])

//CustomField Manager
def customFieldManager = ComponentAccessor.getCustomFieldManager()

//Custom Fields
def isThisIssueA = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_15136"))
def storyPoints = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_17630"))
def testEvidence = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_14030"))
def acceptanceCriteria = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10737"))
def testerField = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_12532"))
def rootCause = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_14931"))

def risk = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_12937"))


if (notASubtask && requiredResolution){
    if (notAtask){
        if ( ! testEvidence && notAnEpic ) {
            report_error("customfield_14030", "Test Evidence field is required")
        }
        if ( ! acceptanceCriteria && notAnEpic ) {
            report_error("customfield_10737", "Acceptance Criteria field is required")
        }
        if ( ! testerField && notAnEpic ) {
            report_error("customfield_12532", "You must specify the tester for this issue")
        }
        if ( ! issue.fixVersions ) {
            report_error("fixVersions", "Fix Version/s field is required")
        }
    }
    if ( ! issue.assignee ) {
        report_error("assignee", "Assignee field is required")
    }

    if ( ! storyPoints && storyPoints != 0 && notAnEpic ) {
        report_error("customfield_10033", "Story Points field is required")
    }

    if ( ! isThisIssueA ) {
        report_error("customfield_15136", "You must specify what type of an issue this is")
    }
}

3 answers

1 accepted

2 votes
Answer accepted
Niclas Sandstroem
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 Leaders.
March 6, 2017

https://answers.atlassian.com/questions/16882890 maybe you run into a similar issue? Are you running this in the correct context from the looks of the error it would seem you are running this with JIRA Misc Workflow Extensions context.

0 votes
kevinbushman March 7, 2017

Hi Niclas, yes thanks I had incorrectly chosen Scripted Validator (Groovy) rather than a custom script under "Script Validator".

image2017-3-7 9:48:28.png

0 votes
Vasiliy Zverev
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 Leaders.
March 6, 2017

Try this code

import com.opensymphony.workflow.InvalidInputException;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager;
import com.atlassian.jira.issue.fields.layout.field.FieldConfigurationScheme;
 
 
def report_error(String field, String message) {
        if (! invalidInputException) {
                invalidInputException = new InvalidInputException("The fields marked below must be filled for issues with resolution of \"${issue.getResolution().getName()}\"")
            }
        invalidInputException.addError(field, message)
}
 
def requiredResolution = ((com.atlassian.jira.issue.Issue) issue).getResolution().getName() in ['Fixed', 'Done', 'Resolved']
 
//Issue Type Variables
def isADefect = issue.issueType.name == "Defect"
def notAnEpic = issue.issueType.name != "Epic"
def notAtask = issue.issueType.name != "Task"
def notASubtask = ! (issue.issueType.name in ['Development', 'Story Defect', 'Sub-task'])
 
//CustomField Manager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
 
//Custom Fields
def isThisIssueA = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_15136"))
def storyPoints = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_17630"))
def testEvidence = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_14030"))
def acceptanceCriteria = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10737"))
def testerField = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_12532"))
def rootCause = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_14931"))
 
def risk = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_12937"))
 
 
if (notASubtask && requiredResolution){
        if (notAtask){
                if ( ! testEvidence && notAnEpic ) {
                        report_error("customfield_14030", "Test Evidence field is required")
                    }
                if ( ! acceptanceCriteria && notAnEpic ) {
                        report_error("customfield_10737", "Acceptance Criteria field is required")
                    }
                if ( ! testerField && notAnEpic ) {
                        report_error("customfield_12532", "You must specify the tester for this issue")
                    }
                if ( ! issue.fixVersions ) {
                        report_error("fixVersions", "Fix Version/s field is required")
                    }
            }
        if ( ! issue.assignee ) {
                report_error("assignee", "Assignee field is required")
            }
     
        if ( ! storyPoints && storyPoints != 0 && notAnEpic ) {
                report_error("customfield_10033", "Story Points field is required")
            }
     
        if ( ! isThisIssueA ) {
                report_error("customfield_15136", "You must specify what type of an issue this is")
            }
}

Suggest an answer

Log in or Sign up to answer