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.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Behavior for requiring IssueLink when setting resolution to duplicate

Nathan Parmeter November 9, 2018 edited

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. 

1 answer

1 accepted

1 vote
Answer accepted
Neta Elyakim
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2018 edited

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)
Nathan Parmeter November 13, 2018

Thank you, figured it was something simple I was missing.

Like Neta Elyakim likes this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

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
AUG Leaders

Upcoming Apps & Integrations Events