Counting Assignees in Child Issues with Jira Automation

Diego Martínez February 7, 2025

Hi Community,

I'm trying to count unique assignees in child issues using Jira Automation. I have a custom field (customfield_18610) that stores assignee usernames separated by commas. For example:

adminbr,Diego,Diego

 

I want to count the number of unique assignees and store that value in another field. I’ve tried the following expressions, but they always return 0:

{{issue.customfield_18610.split(",").distinct.size}}

In this case, the expected unique count should be 2, since Diego appears twice but should only be counted once.

 

Is there a way to properly transform this field into a list and count the unique values using distinct or any other method in Jira Automation?

I’d appreciate any help or suggestions!

 

automation 3.pngautomation 2.pngautomation 1.png

1 answer

0 votes
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.
February 7, 2025

Hi @Diego Martínez 

For a question like this, context is important for the community to help.  Please post the following:

  • an image of your complete automation rule in a single image for continuity,
  • images of any relevant actions / conditions / branches,
  • an image of the audit log details showing the rule execution, and
  • explain what is not working as expected and why you believe that to be the case.

Until we see those...

 

First thing to try: your rule appears to be editing the issue multiple times.

When a rule edits an issue, that updates the database only, not the data the rule has for the issue in-memory.  To get the updated information, the Re-fetch Issue action must be added after the edit to reload the issue data: https://confluence.atlassian.com/automation/jira-automation-actions-993924834.html#Jiraautomationactions-refetchissuedataRe-fetchissuedata

 

If that does not help, please also answer the following:

  • Have you confirmed the custom field is a text field?
  • Have you written the custom field to the audit log to confirm it contains what you expect?  For example, is the delimiter just a comma or is it a comma followed by a space, requiring a change to you split() function parameter.
  • What are you showing with that webhook response parsing of the Assignee field?  Is that the source of the custom field?

 

Kind regards,
Bill

Diego Martínez February 7, 2025

 

 

Here is a complete image of my automation:

Automation completa.png

 

In this action, I take the value from the webhook response and store it in a custom field.

This is an example of the responde that I get adminbr,JIRAUSER22508,JIRAUSER22508 

automation action 1.png

I want the result to be like: adminbr,JIRAUSER22508 instead of adminbr,JIRAUSER22508,JIRAUSER22508, and the count should be 2, since there are repeated values.

For this, I’ve tried using {{issue.customfield_18610.split(",").distinct.size}}, but the returned value is 0.



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.
February 7, 2025

Thanks for that information; it confirms my hypothesis that the problem is due to the missing Re-fetch after the first edit action.

 

Do you need the duplicated values in the custom field, or can that be the distinct ones also?

If you only need the distinct values, you could do this:

  • Create a variable which only has the distinct values.  For example:
    • name: varAssigneeKeyList
    • value:
{{webhookResponse.body.issues.fields.assignee.key.distinct.join(",")}}
  • Use that variable with a single Edit Issue action to set all three fields at one time, with one of these values:
    • {{varAssigneeKeyList}}
    • {{varAssigneeKeyList.split(",").size}}

 

Like Diego Martínez likes this
Diego Martínez February 7, 2025

Hi Bill! :D

I tried using the smart value:

{{webhookResponse.body.issues.fields.assignee.key.distinct.join(",")}}

 

However, it does not return any value.

I assume it should return:

adminbr,JIRAUSER22508

 

If the original value from the webhook response is:

 adminbr,JIRAUSER22508,JIRAUSER22508

 

When I use this smart value to edit the custom field:
{{webhookResponse.body.issues.fields.assignee.key.join(",")}}

 

this is what I get:

adminbr,JIRAUSER22508,JIRAUSER22508

 

And in my currently version of Jira we don't have variables :(

(v8.20.30)

 


 

 

Also, I have already added the Re-fetch action after the first edit, but the issue persists.

 

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.
February 7, 2025

Wow, that is an older version...and was just after distinct was added for Server / Data Center, so I wonder if there are problems in the earlier release.

Let's try this:

  • using your original expression, set the first field (without the distinct)
  • add a Re-fetch Issue action
  • using the Log action, write that first issue field to the log to check what it contains
  • using another Log action, add the distinct to the field to check if it works on just the field split() into a list

 

Like Diego Martínez likes this
Diego Martínez February 7, 2025

I already tried that approach. I first stored the webhook response in a custom field, then applied split() on that field, and finally used distinct() on the result. Unfortunately, it still didn’t work.

I understand that this might be due to the Jira version I’m using, and if that’s the case, there’s probably nothing else that can be done. :(

Thanks for your help! 

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer