Setting up a behavior for requiring an IssueLink when setting resolution to duplicate.
have this:
import com.atlassian.jira.component.ComponentAccessor
def resolutionField = getFieldByName("resolution")
def linksField = getFieldByName("issuelinks")
def resolution = resolutionField.getValue()
if (((IssueConstant) resolution).getName() == "Duplicate") {
linksField.setRequired(true)
linksField.setHidden(false)
}
else {
linksField.setRequired(false)
linksField.setHidden(false)
}
However im getting the following error:
[common.UserScriptEndpoint]: Script console script failed: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script15.groovy: 5: unable to resolve class IssueConstant @ line 5, column 5. if (((IssueConstant) resolution).getName() == "Duplicate") {
Assistance would be appreciated, I'm sure I am missing something but cant figure it out.
You are missing the import for IssueConstant, and you need to take the fields as Id and not by name (those are system fields)
Use this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueConstant
def resolutionField = getFieldById("resolution")
def linksField = getFieldById("issuelinks")
def resolution = resolutionField.getValue()
if (((IssueConstant) resolution).getName() == "Duplicate") {
linksField.setRequired(true)
linksField.setHidden(false)
}
else {
linksField.setRequired(false)
linksField.setHidden(false)
}
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.