Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Is there a way to get the count of items chosen in a select field

trying to take a field that has a list of customers and be able to query for only issues where the number of customers is greater than 1. The field will also have null values at times

1 answer

0 votes
Vasiliy Zverev
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.
Dec 10, 2015

Try using multiuser picker field to store list of customers and calculated field (provided by ScriptRunner) with this script to store it count

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField

/**
 * Get number of users for multiuser picker
 */
CustomField multiuserCstFld = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("FieldName")
if (multiuserCstFld == null)
    return "custom field not found"

return "" + ((ArrayList) multiuserCstFld.getValue(issue)).size()

I've tried this on the 'Components' field and receive an error:

"custom field not found"

Does this not work on OOTB fields?

Vasiliy Zverev
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.
Jan 01, 2019

Components is not a custom field.

You should method of Issue class use https://docs.atlassian.com/software/jira/docs/api/7.1.2/com/atlassian/jira/issue/Issue.html#getComponents-- 

Like # people like this

So what would this look like in order to have a field that showed the number of components?  Since it's not a custom field?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events