Is there a way in automation to count the number of users in a custom field (multi user picker)

Ryan B. Gonzales April 12, 2022

Hello JIRA Experts,

 

Just wanna know if there's a way in automation to count the number of users in a multi-user picker (custom field).

 

Thanks,

Ry

 

3 answers

3 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 12, 2022

Hi Ryan,

I think you should be able to do this with the size function and Smart values. See if the below gets you what you seek.

value = {{issue.customfield_xxxxxx.size}}

Bill Sheboy
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.
April 12, 2022

Hi @Ryan B. Gonzales 

Yes, and to Jack's answer: to ensure that count is always a number, you may add a default so NULL is replaced with zero.  For example:

{{issue.customfield_xxxxxx.size|0}}

Kind regards,
Bill

Like Jack Brickey likes this
Ryan B. Gonzales April 17, 2022

Hi, @Jack Brickey  and @Bill Sheboy 

 

Thanks for your reply, just want to confirm first if {{issue.customfield_xxxxxx.size}} is working in JIRA software?

 

Tried to test it now, but I got zero results. I am not sure if the suggested size function and smart values is only applicable in JIRA Service Management.

 

Thanks,

Ryan

Bill Sheboy
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.
April 18, 2022

The size function works for a smart value list in any of the products.  Have you confirmed the smart value name or custom field number is correct?  Perhaps try writing it to the audit log to confirm that.

And if it is not correct, you may find that information using this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

This could also be related to the structure/placement of actions within your rule.  Would you please post an image of your complete rule for context?  Thanks!

Ryan B. Gonzales April 25, 2022

Hi @Bill Sheboy

 

1. I have this automation when the user transitions the status of the ticket from Requirement Specification to For Approval it counts the number of users from a custom field (multi-user picker) and assigns it to a custom number field.

1.png

2. This is the custom field I've created for the multi-user picker (issue.fields.customfield_10423) and I am assigning its size of it to a custom number field (Approver_count)

2.png

3. Before the transition to For Approval Status, initial value is None

3.png

4. After the transition, the automation status is SUCCESS

4.png

 

5. However, the value of Approver_count field was defaulted to 9999 which means that the automation capture null for the size of Approver(s)field.5.png

Ryan B. Gonzales April 25, 2022

Also, I see this site saying that the said size function and smart values are only applicable in JIRA Service Management.

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-insight/

Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 25, 2022

I think that page is about Insight object operations. I believe the "size" operator works for JSW and JWM as well but haven't played with it. I will try to do so today.

Like Ryan B. Gonzales likes this
Ryan B. Gonzales May 1, 2022

Hi, @Jack Brickey 

Just want to check if you already tried it?

Regards,

Ryan

Petr A November 2, 2022

Thanks for the discussion!
How do you think, is it possible to get a list of tasks whose size is >2 for example?
Now I get an error when comparing that this field was not found.

{{issue.customfield_XXXXX.size|0}} > 2 


Custom Smart Value JQL Search: "(3 > 2 and project = test) AND (project in (xxxxx))" - Field '3' does not exist or you do not have permission to view it.

Not that it was very important, but just out of principle, I can’t understand if this is possible without changing the issue itself, mb through variables, or lookup.

Thanks already:) 

Bill Sheboy
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.
November 2, 2022

Hi @Petr A 

With out-of-the-box JQL features, it is not possible to query the number of selections/values in a field that can be interpreted as a list.

Some work-arounds are:

  • for a one-time/few-times approach, export the issues to another tool or spreadsheet, and perform the analysis there
  • using an automation rule, gather issues to check (i.e. scheduled trigger with JQL, branch, or lookup issues), and then check the size in the rule
  • using a custom field and an automation rule, save the number of values selected/included in the custom field, and then you may use standard JQL to query that custom field
  • buy a marketplace addon for JQL which supports this type of query

 

Kind regards,
Bill

Like Petr A likes this
Petr A November 3, 2022

Hi @Bill Sheboy 

Yeah, true, It's nearly impossible to lookup via this condition, 

The best way to export to Excel and count up then, or check keys an automation rule, you are right!

Thanks!

Like Bill Sheboy likes this
0 votes
Inayat N August 10, 2023

Is this also possible with a scripted field using Scriptrunner?   To count the number of users in a multi user-picker field, and also return 0 if none?

0 votes
Marcelo Ignacio Cid Abud April 19, 2023

Hi @Jack Brickey

Is there any way to count the tickets when they are created?

Fox example:

I create the ticket MAR-1 and the customefield correlative = 1

I create the ticket MAR-2 and the customefield correlative = 2

....

Marcelo Ignacio Cid Abud April 19, 2023

For this I have the customefield = Correlative and this field is a number field

Bill Sheboy
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.
April 19, 2023

Hi @Marcelo Ignacio Cid Abud 

This seems to be a duplicate of your other question.  Please look there for responses: https://community.atlassian.com/t5/Jira-Software-questions/Count-Issue-Types/qaq-p/2337031

Thanks, and kind regards,
Bill

Suggest an answer

Log in or Sign up to answer