Forums

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

Using Scriptrunner, want to make Linked Issues field mandatory based on Resolution value

Chaya February 16, 2023

If resolution of the field is set to "Duplicate" then I want to make Linked Issues field mandatory such that Issue won't transition and user will get error.

I tried below script in behavior, but it is not working:

 

def resolution = getFieldById("resolution")
def resolutionValue = resolution.getFormValue()
def issueLinkType = getFieldById("issuelinks")

if(resolutionValue == "Duplicate"){
    issueLinkType.setRequired(true)
} else{
    issueLinkType.setRequired(false)
}

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Chaya February 22, 2023
def resolution = getFieldById("resolution")
def resolutionValue = resolution.getFormValue()
def issueLinkType = getFieldById("issuelinks")

 

if(resolutionValue == "10003"){
    issueLinkType.setRequired(true)
else{
    issueLinkType.setRequired(false)
}
Above script worked for me. Instead of using resolutionValue as a string, you need to use id.
0 votes
PD Sheehan
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.
February 16, 2023

For system fields (as opposed to custom fields), I think it's best (and perhaps necessary) to use "getFieldById()"

In this case, it would be something like this (untested)

def resolution = getFieldById( 'resolution' ).value
if (resolution == "Duplicate" ){
getFieldById("issuelinks").setRequired( true )
}

Or possibly

def resolution = getFieldById( 'resolution' ).value
if (resolution == "Duplicate" ){
getFieldById("issuelinks-issues").setRequired( true )
}
Chaya February 16, 2023

Both the scripts are not working. I have resolution field available on Resolve Issue Screen which is used only on last transition where I set Resolution. I also added Linked Issues field to that screen. 

TAGS
AUG Leaders

Atlassian Community Events