Validate that all linked issues are DONE - ScriptRunner Cloud

Daniel Alonso May 14, 2021

I created this question months ago, and we are now migrating to Cloud.

Is there a way someone can help me to translate the following code to Script Runner Cloud:

{code}

import com.atlassian.jira.component.ComponentAccessor
def linkMgr = ComponentAccessor.issueLinkManager
linkMgr.getLinkCollection(issue, currentUser).allIssues.findAll{it != issue}.every{it.resolution}

{code}

Thanks in advance!

Daniel

1 answer

1 accepted

2 votes
Answer accepted
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 15, 2021

So, I'm not exactly sure what your Groovy is doing (because I don't see it checking for "Done"), but ScriptRunner (and all validators) have to use Jira Expressions.

So to "Validate that all linked issues are DONE" this should work:

issue.links.filter(L => (L.linkedIssue.status.name == 'Done')).length ==
issue.links.length

I looked at the Jira Expressions examples for ScriptRunner here:
https://scriptrunner-docs.connect.adaptavist.com/jiracloud/validators.html

And also this old answer, although I think the final code is wrong:  https://community.atlassian.com/t5/Jira-questions/Jira-expression-to-validate-linked-issue-status/qaq-p/1300463

I tested my code using the excellent Jodocus Expression Tester.

Daniel Alonso May 17, 2021

Perfect!! Thanks for the suggestion of the Expression Tester, very useful.

Anees Sultana October 28, 2021

Hi Darryl,

 

issue.links.filter(L => (L.linkedIssue.status.name == 'Done')).length ==
issue.links.length

 Thank you for your code, it did worked.

Also i have another follow up question , instead of all linked issues if i want to check only specific linked issue type

Types are

Is blocked by

is cloned by

 

i want to check only "is blocked by" are Done or not. Can you please help me with code.

I am new to script runner cloud

 

Appreciate your help

 

Thanks,

Anees

Suggest an answer

Log in or Sign up to answer