It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

2 votes
Answer 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.

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
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,639 views 8 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you