{{lookupissues.customfield.distinct}} returning duplicates

Daniel Landino June 1, 2022

Hi Everyone!

Background: using {{lookupissues}} in automation for slack messages in a variety of ways but have been unable to figure out how to successfully utilize the distinct function to remove duplicates for a text-based custom field

(documented here under list.distinct)

Closest thing I have found on the community is (Automation distinct and formatted ) but to be honest it's a bit over my head and really looking for some help!

Example: 

  • Let's say customfield_16575 is for Name and the 5 results from the lookupissues filter I'm using are: Dan, Dan, Dan, Alex, Rob.
  • I'd want it to output: Dan, Alex, Rob
  • Instead {{lookupIssues.customfield_16575.distinct}} results in Dan, Dan, Dan, Alex, Rob

Any insight and help is greatly appreciated, I've spent many hours trying a lot of stuff unsucccessfully. 

 

2 answers

1 accepted

0 votes
Answer accepted
Garrett McCreery
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.
June 3, 2022

@Daniel Landino 

The lookupIssues function doesn't contain custom fields. it only has a few fields that you can reference (see: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#Available-properties)

You will have to build your list some other way than lookupissues. Once you have that, then you can use the split with the distinct function that I mentioned in the other solution: 

https://community.atlassian.com/t5/Jira-Software-questions/Automation-distinct-and-formatted/qaq-p/2017250?utm_source=atlcomm&utm_medium=email&utm_campaign=mentions_reply&utm_content=topic

Daniel Landino June 3, 2022

bummer on the custom fields but much appreciated for your help and quick reply!

I'll think through how/if I can tackle this another way.

Cheers

Daniel Landino June 3, 2022

To clarify a little, I thought the custom fields wouldn't be supported due to that documentation but I am able to output a list with {{lookupIssues.customfield_16574}} .

It's just the distinct aspect that isn't working

Garrett McCreery
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.
June 3, 2022

Ok... Then try adding the lookupissues to a variable "myList" like this notice the comma on the end:

{{#lookupIssues}}{{customfield_16574}},{{/}}

Then using that variable "myList" create another variable "myDistinctList":

{{myList.split(",").distinct}}

 

Maybe that will work?

Like # people like this
Daniel Landino June 3, 2022

YESSSSSSSSSSSSS!

you have no idea how happy I am. Thank you so much

Like John Funk likes this
Garrett McCreery
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.
June 3, 2022

Glad I could help!

Like John Funk likes this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 3, 2022

Hey Daniel - Can you publish your actual rule with the code showing so future people looking here can see the solution you used? Thanks!

Like Daniel Landino likes this
Daniel Landino June 6, 2022

Certainly!

  1. It's a scheduled rule:
    1. 0 59 14 ? * MON-FRI
  2. Then Lookupissues
    1. project = "Test-Project" AND "Date" = startOfDay(0)
  3. if:matches
    1. if {{lookupIssues.size|0}} does not equal 0
      1. Then: create variable
        1. variable name = myList
        2. smart value = {{#lookupIssues}}{{customfield_16575|"not specified"}},{{/}}
      2. Then: create variable
        1. variable name = myDistList
        2. {{myDistList.split(",").!="not specified".distinct}}
  4. And: Send Slack Message
    1. # of Things Scheduled Today: *{{lookupIssues.size}}*
      *Locations:* {{myDistList}}
  5. There's an else-if: matches here but not important for this example

customfield_16575 refers to locations, I'm also messing around with the inputting "not specified" for invalid references - when testing I found that if customfield_16575 was left blank I would get some wonky results, e.g "America, Mexico, , Canada"

Like # people like this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2022

Awesome - thanks for sharing that!

1 vote
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 2, 2022

Hey Daniel, 

I have not tried the function before, but looking at the documentation, maybe try this:

{{lookupIssues.customfield_16575.split(",").distinct}}

Daniel Landino June 3, 2022

no dice, that ^ actually returns a blank message but I do appreciate the attempt!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events