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!
For a question like this, context is important for the community to help. Please post the following:
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:
Kind regards,
Bill
Here is a complete image of my automation:
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
{{webhookResponse.body.issues.fields.assignee.key.distinct.join(",")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.