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") } }
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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") } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.