Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Groovy script to determine project for linked issue

Richard Gianattasio
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 29, 2020

Using the solution found here: https://community.atlassian.com/t5/Answers-Developer-Questions/Check-if-linked-issue-is-in-a-certain-project/qaq-p/564203

I have added the below groovy script to the Set Field Value of Related Issues Post-function being used in my workflow so that I can conditionally execute the function when the Linked issue is in a specific project.   

Here is the script: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink

def io = ComponentAccessor.getIssueManager().getIssueObject(issueObject.getKey())
def issueLinkManager = ComponentAccessor.getIssueLinkManager()

issueLinkManager.getOutwardLinks(io.id).any{it.destinationObject.getProjectObject().getKey() == 'S1S2'}

What I am finding is that the array is always null, so the last line will always be false.

It is properly resolving the issue, but the linked issue is not resolving.

When i change the last line to getInwardLinks I get a non-null array, but the information does not look correct and still resolves as false.

My issue has an "addresses" link.

1 answer

0 votes
Radhika Vijji _Innovalog_
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.
June 29, 2020

Hi Richard,

With the simplified API of JMWE, your script can be much simpler. 

relatedIssue?.project?.key == "S1S2"

relatedIssue here refers the related/linked issue being processed by the post-function, in turn. 

Regards,

Radhika

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Jira Events