How to get unique value from multi-select using smart value?

Keith Vedol January 27, 2023

Hi,

I am creating an automation rule that gets the unique values from a multi-select field in order to populate a list.  Being that this field allows multiple selections for the tickets (ex. C++, Unity, Javascript), there will be other tickets in the same release that will have one or more of the same values selected. The following smart value was created for the rule:

{{lookupIssues.customfield_12345.value.distinct}}

Example:

Three tickets are in the release.

One has C++ only selected in the aforementioned field.

The second has C++, Unity selected.

The third has C++, Unity, and JavaScript selected.

Run the rule.

 

The result when the email is received:

 [C++, C++, Javascript, Unity, C++, Unity] 

The expected would be to just have the unique values appear to represent what was worked on for the release.

Is there a way to just get only the unique values in the list of tickets to be returned?  Any guidance would be appreciated. Thanks.

1 answer

1 accepted

5 votes
Answer accepted
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.
January 28, 2023

Hi @Keith Vedol 

That is working as expected...What is happening is the distinct function is applying to the set-of-selections for your custom field, and with 3 choices there could be 2^3 or 8 possible results.

The work-around is to merge the sets before using distinct.  Please try this one:

{{lookupIssues.customfield_12345.value.join(",").remove("[").remove("]").replace(", ",",").split(",").distinct}}

How this works: 

  • The lookup returns zero-to-many issues, and your custom field has zero-to-many selections...
  • and so each "value" is an array (not a list)
  • First we merge everything across the arrays with a comma using the join function,
  • Then remove any brackets around the arrays
  • And then remove any stray spacing from ", " versus "," differences.
  • Now we can split into a list
  • And finally use distinct again.

Please note the results may not match the order of your selection list items.  A work-around for that is to add ORDER BY cf[12345] ASC to your lookup issues JQL, as that will at least be in alphanumeric sort order.

Kind regards,
Bill

Keith Vedol January 28, 2023

Hi @Bill Sheboy

The solution you advised works perfectly.  Thank You for the response and the assistance!

 

Regards,

Keith

Like Bill Sheboy likes this
Pavol Sočuvka February 1, 2024

Hi @Bill Sheboy

Please, do you have an idea how to achieve this result with a list of users, when using custom field multi user picker? I am able to get a list of distinct account IDs this way but I can't email them.

I'm trying to achieve this automation trick but with multi user picker so users potentially receive multiple emails.

Thank you for any advice.

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 1, 2024

Hi @Pavol Sočuvka 

Perhaps...it is the same concept, except using the "value.emailAddress" attribute rather than "value" as shown above.  The reason is the user picker fields returns user objects, and that will include all the needed attributes.

To confirm this the community would need to see your rule and know your project type: company-managed or team-managed.  This technique will not work for a team-managed project's People-type fields, as those do not provide an email address.

Kind regards,
Bill

Pavol Sočuvka February 2, 2024

Hi @Bill Sheboy 

Thank you for your reply. I think we've figured it out in the end. We are in company managed projects.

Let's call the multi user picker field "Solvers".

We do an advanced branching with Bill's join-and-split technique so we get a list of distinct email addresses.

{{lookupIssues.customfield_10525.emailAddress.join(",").remove("[").remove("]").replace(", ",",").split(",").distinct}}

For each address, we Lookup issues. The trick was to coat the smart value in quotation marks, so email address works:

Solvers in "{{advancedBranch}}"

The rest is easy peasy, follow the KB article linked in my previous comment.

Cheers,

Like # people like this
LuisPinto February 21, 2025

Hello,

I'm trying to create an automation rule very similar to the one Keith Vedol mentioned, but I'm having some problems with updating the field with the list of values.

In my case, I want to keep a field of an issue updated with all the values that the child issues have for the same field.

I've created a rule that every time there's a change to this field, it fetches the values for the field from all the child issues to update the parent issue. I can get the list with the unique values, but I can't update the parent field with that same list.

Can you help me?

Screenshot_10.png

LuisPinto February 21, 2025

Hello @Bill Sheboy can you help me? I forgot to mention you in my reply

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 21, 2025

Hi @LuisPinto 

This is a very old thread, and so I recommend creating a new question.  That will ensure the maximum number of people see it to offer suggestions, and to help focus on your question.

When you create your question, perhaps add a link back to this thread, and include the following for context:

  • what type of project are you using: company-managed or team-managed
  • what is the type of the field you are trying to update in the parent
  • an image of the complete rule in one single image for continuity
  • images of any relevant actions (e.g., the create variable and edit issue actions)
  • an image of the audit log details showing the rule execution, with all of the areas expanded to show the details
  • explain what is not working as expected, and why you believe that to be the case

 

Kind regards,
Bill

Like LuisPinto likes this
LuisPinto February 21, 2025

@Bill Sheboy i will create a new question with all the details you said. Thank you

 

Best regards,

Luis

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events