Is it Possible to narrow down Linked Issues Condition to a specific issue type

Michael Wheatstone March 14, 2024

I am currently using the below expression to check if a linked issue has been set to done before the workflow allows the issue to move to the next step in the workflow.

// Check all linked issues of a certain link type are at certain status
issue.links
    .filter(l => l.type.inward == 'To be done with')
    .every(l => l.linkedIssue.status.name == 'Done')

I now need to clarify the check so that it only prevents the issue from transitioning if a specific issue type is linked with the 'To be done with' link type and that linked issue is set to done.

I will admit Jira expressions are not my strong suit and so would appreciate any assistance

Kind regards

Michael

1 answer

2 votes
Rik de Valk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2024

Hi @Michael Wheatstone , 

Out of the box this is not possible. But I think you're using a Condition provided by some Marketplace App to achieve this. 

If you mention which Marketplace App you are using, then community members who have experience with this app might be able to help. 

For example, if you have Jira Misc Workflow Extensions, you can use the 'Linked issue status condition': https://appfire.com/resources/blog/jmwe-cloud-guide-configuring-workflow-conditions 

Have a nice day, Rik

Michael Wheatstone March 14, 2024

Hi Rik.

Yes apologies I am using a  ScriptRunner Script to Add a ScriptRunner Script Condition that evaluates a Jira Expression to determine whether to allow the transition.

Floating electron
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 14, 2024

Following Jira expression should allow transition if the linked issue (link: "To be done with" has issue type: "Task" and is in status category: "Done"

issue.links
.filter(link => link.type.name == "To be done with" && link.direction == 'inward')
.map(link => link.linkedIssue)
.filter(issue => issue.issueType.name == "Task")
.reduce((pass, issue) => pass && ['done'].includes(issue.status.category.key), true)

 Of course, it would be better to use link.id and issueType.id instead of names. If you want to check status, instead of status category, replace issue.status.category.key with issue.status.name.

For those who don't have Script Runner, we have created Linked Issues Validator in wizard-like style, for which you don't need Jira expression knowledge. Leaving this here in case anyone need it: https://marketplace.atlassian.com/apps/1233642/workflow-building-blocks-for-jira?hosting=cloud&tab=overview

Michael Wheatstone March 14, 2024

Hi Floating Electron.

While this seems close from my basic understanding of Jira expressions, when I use it, it is allowing the issue to transition regardless of what issue types are linked, and what the status of those issues are.

So it works for letting issues move forward, but it is not preventing issues that don't meet the criteria from transitioning.

My old expression would check link type and if the linked issue was done, I was hoping to expand this so it would check the link type, if the issue is a particular issue type, and if it was set to 'Done'

Floating electron
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 14, 2024

If you require that the link must be of issue type: "Task" and status "Done", then:

issue.links
    .filter(l => l.type.inward == 'To be done with')
    .every(l => l.linkedIssue.status.name == 'Done' && l.linkedIssue.issueType.name == "Task" )

 If you want to check only the status of links with the issue type: "Task", then:

issue.links
    .filter(l => l.type.inward == 'To be done with')
.filter(l => l.linkedIssue.issueType.name == "Task") .every(l => l.linkedIssue.status.name == 'Done' )

 

Michael Wheatstone March 14, 2024

Hi Floating Electron

The above works in testing when i run the script tests before applying to the workflow but is still not working in practice.

I think you're on the money though so I am going to look elsewhere to see if something else is allowing no compliant issues to get past even though the script should be preventing them.

 

Thanks for your assistance.

Like Floating electron likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events