JQL query to fetch issues linked to a bug with 'relates to' in order

raghuvarmaofficial March 23, 2023

I am trying to fetch issues linked to a bug in the order of their linking time

ex story-1 story-2 story-3

if story-2 is linked to bug first followed by story-3 and story-1

I want to write a jql query that can fetch me these issues on their order of linking any order either Asc or Des like

story-2,story-3,story-2


issue in linkedIssues({{issue.key}}, "relates to") And issueType = story

I was able to get this far but not able to get them in the order of linking

1 answer

0 votes
Trudy Claspill
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 24, 2023

Hello @raghuvarmaofficial 

Native Jira JQL functionality does not support ordering issues based on the date/time that a link was created between two issues. The date the link was created is documented in the history for each issue in the pair. The ORDER BY clause in JQL generally cannot be applied to information that is embedded in issue history. Rather it is used with the issue fields like Status, Created, Components, etc.

Given that you included {{issue.key}} in your JQL I suspect that you are trying to do this within the context of an Automation Rule.  You might be able to find a method accessible within an Automation Rule to parse the history for each retrieved issue and pull out the entry for when the link to the bug was created. I'm afraid I don't have that level of expertise.

Suggest an answer

Log in or Sign up to answer