Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Counting the number of components attached to a Jira issue

Is there a way in JQL to count the number of components attached to an issue?

4 answers

1 accepted

0 votes
Answer accepted

So I got this working with the JIRA Misc Custom Fields plugin.

Creating a new custom field (Calculated Number Field), using the following formula in the field description:

<!-- @@Formula: (issue.get("components") != null) ? issue.get("components").size() : 0 -->

For some reason this gave me issues when I configured the field to a specific issue type. When I configured it for Global (all issue types) it showed up in my issue navigator columns, and I can reference the field in the JQL editor.

Sorting the "counted" result is somewhat strange. It seems 0 is greater than any other number. I can live with this though.

As Christian says. You could add a scripted field which calculated the number of components, which you don't need to put on any screens. Not ideal for ad hoc reporting though.

The other thing to do would be to hit the db directly... far from ideal.

Thanks for the reply.

I got a little further with the Calculated Number Field from the JIRA Misc Custom Fields plugin. I used the formula <!-- @@Formula: issue.get("components").size() --> in the field description (as pr. the documentation)

When I go to Issue Navigator -> Configure columns to add my new "count components" field, it will show a 10 issue preview with data, where the count value is shown correctly in the new column.

When I go back to the issue naviagtor, the new column has disappeared. I cannot reference the new field in a JQL query either. So it seems the field is doing what I want - I just cannot get the result where I want it.

I'll keep poking around. Any feedback is much appreciated!

I was talking about a scripted field from the script runner plugin, I'm not qualified to speak to the one you used I'm afraid.

Ok, thanks Jamie. I will be sure to check out the script runner plugin!

None that I would know of. I mean JQL is sth. like a WHERE clause. You don't have functions like SUM so you can't count.

Does anyone know where I can find a ScriptRunner Script that can do this? 

Suggest an answer

Log in or Sign up to answer
TAGS

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