Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Atlassian Community Events