Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×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.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.