Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How traverse through a List and count the number of items matching a particular string

Hi,

I am looking to figure out how to traverse through a list (in this case, "issuelinks" and:

a) Count the total number of inward links

b) Count the number of inward links that have a status of done

I know how to:

- Count the # of inward links, using:

{{issue.issuelinks.inwardIssue.size}}

- Identify the status of each inward link, using:

{{#issue.issuelinks.inwardIssue.fields.status}}{{name}}{{/}}

- Determine if that status of an inward link is Done using; {{#issue.issuelinks.inwardIssue.fields.status}}{{name.equals(“Done”)}}{{/}}

But, I am unable to figure out how to count the # that are not Done.  Ultimately, I want to set counters (custom fields) with following values: Count of Incoming Links that are Open, Count of Incoming Links that are Done and display these in Jira Dashboards.

Any ideas?

Thanks,

Doug

 

 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Doug Levitt 

Your conditional expression to find the linked issues with a "Done" status is returning a list of comma-separated values.  If you stick that into a created variable, e.g. varDoneList, you could then count them:

{{varDoneList.split(",").size}}

To get the non-done count, just subtract that from your total count.

Kind regards,
Bill

Hi @Bill Sheboy 

Thanks.  That is very helpful.

As I think about my ultimate solution, I have a more complex question...

Assume, I have the following links:

  • Blocker
    - inward: "is blocked by",
    - outward: "blocks",

According to the json structure, each link is associated with a:

  • Type which has a name {{issuelinks.type.name}} -- e.g. Blocker
  • Inward value {{issuelinks.type.name.inward}}  -- e.g. "is blocked by"
  • Outward value {{issuelinks.type.name.outward}} -- e.g. "blocks"

So, I am now interested in populating the following custom fields for each jira issue:

TicketsIamDependentOn

  • Contains the keys of all links of type "is blocked by" (which is an inward link)
  • I want to ignore inward links of other types and all outward links
  • Note: keys for inward links are stored in {{issuelinks.inwardIssue.key}}

TicketsThatDependentOnMe

  • Contains the keys of all links of type "blocks" (which is an outward link)
  • I want to ignore outward links of other types and all inward links
  • Note: keys for outward links are stored in {{issuelinks.outwardIssue.key}}

countOfAllDependentLinks

  • Contains the count of all links which are set to "is blocked by"
  • I want to ignore inward links of other types and all outward links

countOfOpenDependentLinks

  • Contains the count of all links which are set to "is blocked by" which are not Done
  • I want to ignore issue links of other types and all outward links
  • Note: Status is stored in {{issuelinks.outwardIssue.status.name}}

I suppose I don't want to simply count the entries in the issuelinks list.  Rather, I want to take action based upon other attributes in the json. I am unclear how to specify this. Any ideas or pointers on how to do this?

Thanks,

Doug

Hi, Doug!

I believe what you ask is possible with list functions and the list filtering capability:

https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

With that, you probably can pull out the keys by type into a created variable, and then use that for your dependency list and count.  Removing any two-way duplicates (due to multiple linkages types) could be a bit tricky.

I recall previously doing something like this as an experiment with variables, lists, text, and regular expressions.  This new feature seems much better.

Kind regards,
Bill

Like Doug Levitt likes this

Hi @Bill Sheboy 

Wow.  That new feature is cool.  I will definitely give it a try.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

90 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you