Forums

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

Can I limit Issue Link Types to certain projects?

Mahima Srivastav
Contributor
August 2, 2021

Can I limit Issue Link Types to certain projects?

3 answers

0 votes
Makareswar Rout September 3, 2022

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours
def log = Logger.getLogger(getClass())
log.setLevel(Level.DEBUG)

FormField linkTypes = getFieldById("issuelinks-linktype")

linkTypes.setFormValue(['Used by Application(s)'])
linkTypes.setReadOnly(true)
Makareswar Rout September 3, 2022

Add the above code under "Linked Issue" field  for your project behavior .

Makareswar Rout September 3, 2022

for both inbound and out-bound:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours
def log = Logger.getLogger(getClass())
log.setLevel(Level.DEBUG)

FormField linkTypes = getFieldById("issuelinks-linktype")

def allowedOutwardTypes = ["Used by Application(s)"]
def allowedInwardTypes = ["Has Exception(s)"]

 

//Please make sure you have this option configured in issue linking globally.

IssueLinkTypeManager issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)


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

Map inwardAllowedLinks = issueLinkTypeManager.getIssueLinkTypes(false).findAll{ it.inward in allowedInwardTypes }.collectEntries{
[it.inward,it.inward]
}


def allowedLinks = outwardAllowedLinks << inwardAllowedLinks

log.debug("Allowed Links = $allowedLinks")

0 votes
Fabian Lim
Community Champion
August 2, 2021

Hi @Mahima Srivastav

I recommend the following plugin: https://marketplace.atlassian.com/apps/1214172/extended-schemes-for-jira?tab=overview&hosting=server 

It's a life saver if you are trying to reduce the number of options for issue links and resolution options per project.

Dirk Ronsmans
Community Champion
August 2, 2021

Hey @Fabian Lim ,

As @Mahima Srivastav tagged this question as Cloud that might not work. I fear there is no cloud version of this app available.

Like Fabian Lim likes this
0 votes
Dirk Ronsmans
Community Champion
August 2, 2021

Hey @Mahima Srivastav ,

Unfortunately issue link types are configured globally.

There is however a suggestion available for it https://jira.atlassian.com/browse/JRACLOUD-36494

Suggest an answer

Log in or Sign up to answer