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

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

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 vote
Vasiliy Zverev Community Champion Mar 06, 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")
            }
}

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

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 Thursday in Confluence

Color tables for a shiny Confluence page

...; ## Developed by: Alana Fernando ## Shared with love ## @param style:title=style type|type=enum|required=true|desc=Choose a style.|enumValues=Style1,Style2,Style3,Style4,Style5 ## @param alignment:title...

145 views 8 11
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