I need a method to count the number of links that an issue has. I see in the scriptrunner docs that there is numberOfLinks. Can that be used in a scriptrunner script?
https://scriptrunner-docs.connect.adaptavist.com/jiracloud/jql-aliases.html#_linked_issues
If not, what is the method to loop through links and increase a count?
Hi Alexandar,
Thank you for your question.
I can confirm that ScriptRunner for Jira Cloud does not provide any JQL functions to search for how many linked issues an issue has out of the box.
However, I can confirm that it is possible to create a Script Listener which calls the Search API and runs a JQL search to get the required linked issues and then counts the number of these and stores these in a field on the issue that triggered the listener.
I can confirm we have an example in the documentation page located here which shows how to count the number of subtasks on an issue using this approach, and you will be able to use this script as a reference guide to help you create the script that you require.
I hope this information helps.
Regards,
Kristian
Thanks for your response.
Why is the search split up into multiple lines?
def allSubtasks = get("/rest/api/2/search")
.queryString("jql", "parent=${parentKey}")
.queryString("fields", "[]")
.asObject(Map)
.body
.issues as List<Map>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
Thank you for your response.
I can confirm the rest call requires all these lines as is the structure that the Atlassian API requires to search for issues in groovy and is split into multiple lines to format it to make it easy to read and understand and to follow good coding practices.
To explain your structure above I can confirm that
I hope this information helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.