Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,224
Community Members
 
Community Events
165
Community Groups

{{lookupissues.customfield.distinct}} returning duplicates

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

@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

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

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

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 Daniel Landino likes this

YESSSSSSSSSSSSS!

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

Like John M Funk likes this

Glad I could help!

Like John M Funk likes this
John M Funk Community Leader Jun 03, 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

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 M Funk Community Leader Jun 06, 2022

Awesome - thanks for sharing that!

1 vote
John M Funk Community Leader Jun 02, 2022

Hey Daniel, 

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

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

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
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

357 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you