ScriptRunner Script or Behaviour to Limit Linked Issues to Certain Issue Types

Shawna Morris March 22, 2021

Good Afternoon!

Let me outline what it is I'm trying to get to. 

Background Information: We have Epics, Features, and Enablers in Project B. Before any of these issueTypes can be progressed beyond a "New" status, they have to be a "Child of" issueLink to something (they're supposed to be a "Child of" an Initiative issueType, but people will put anything there to move their issue).

Ask: I want it to be that an Epic/Feature/Enabler cannot progress beyond New UNTIL it's a "Child of" an Initiative issueType (in Project A). 

I am not the best coder, just being honest. But I cannot, for the life of me, figure out how to do this via a ScriptRunner validation/script or Behaviour. 

Can someone help! Please and thank you! 

1 answer

0 votes
C_ Derek Fields
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.
March 22, 2021

Here is a start. You would install this as a Script Condition using ScriptRunner.

import com.atlassian.jira.component.ComponentAccessor;

final String LINK_TYPE = "DUPLICATE";
final String ISSUE_TYPE = "Initiative";

def linkManager = ComponentAccessor.getIssueLinkManager();
def links = ComponentAccessor.getIssueLinkManager()
.getLinkCollectionOverrideSecurity(issue)
.getOutwardIssues(LINK_TYPE)
.find{
it.getIssueType().getName() == ISSUE_TYPE
};

You need to update the Link Type and the Issue Type to match what you want. This particular code does not check that the outward linked issue is in a specific project. You can add that in the find closure if you want.

I hope that this helps.

Shawna Morris March 24, 2021

I'm going to try this. For now, I've created two additional customFields (issuePicker with a JQL). But, this has the potential to be much cleaner.

Suggest an answer

Log in or Sign up to answer