Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,162
Community Members
 
Community Events
168
Community Groups

Can I limit Issue Link Types to certain projects?

Can I limit Issue Link Types to certain projects?

3 answers


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)

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

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 Leader Aug 02, 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 Leader Aug 02, 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 Leader Aug 02, 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
TAGS

Atlassian Community Events