Forums

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

How to show Issue Links based on radio button option of custom field

Sabine Van Regenmortel
Contributor
August 3, 2022

Hi,

In transition screen Close Abort, I want to show only the linktype 'duplicates' when a certain option 'Duplicate' (ID 10220) is chosen in a radio button custom field 'Abort Why'.

I tried this script behaviour both on the Linked Issues field and the Abort Why field, but it doesn't work.  Only the hiding works, but not the radio button option condition.
I used both ID 10220 and Duplicate.

Any ideas?

 

import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours

@BaseScript FieldBehaviours fieldBehaviours

def issueLinkType = getFieldById("issuelinks-linktype")
issueLinkType.formValue = "duplicates"

def issueLinkValue = getFieldById("issuelinks-issues")
def abortwhy = getFieldById("customfield_10111")
def abortwhyValue = abortwhy.formValue.toString()
def screenName = "Close Abort"

issueLinkType.hidden = true
issueLinkValue.hidden = true


if (abortwhyValue == "10220" && actionName == screenName) {
issueLinkType.hidden = false
issueLinkValue.hidden = false
}

1 answer

0 votes
Aditya Sastry
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.
August 3, 2022

Hi Sabine,

Kindly check the below behaviour. Minor modifications may be required as I haven't tested it on my system but I believe it should work. Please mark the answer as accepted if it works for you.

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def issueLinkType = getFieldById("issuelinks-linktype")
def allowedTypes = ["approves"]
def abortwhy= getFieldById("customfield_10111")
def abortwhyValue = abortwhy.formValue.toString()
def screenName = "Close Abort"


IssueLinkTypeManager issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)

Map outwardAllowedLinks = issueLinkTypeManager.getIssueLinkTypes(false).findAll{ it.outward in allowedTypes }.collectEntries{
[it.outward,it.outward]
}

def allowedLinks = outwardAllowedLinks


if (abortwhyValue == "Duplicate" && actionName == screenName) {
{

issueLinkType.setFieldOptions(allowedLinks)

}

Thanks,

Aditya

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.22.6
TAGS
AUG Leaders

Atlassian Community Events