Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Automation distinct and formatted

Edited
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 02, 2022

Hey there community,

I'm trying to set up a rule that is getting quite complex and hoping someone here can help me out.  Here's what I have so far in the rule:

  • I have a look up issues action that pulls in all blocked issues
  • I have a variable (varMyVariable) that gives me the Insight object attribute off of each of the blocked issues which is always numeric.  The variable looks like this:
    • {{lookupIssues.customfield_xxxxx."My ID"}}  
  • The results look something like this:
    • [123], [234], [345], [234], [789], [321], [1], [1], [10], [45], [654], [555],[54], [222], [777]

So far so good... Now I have some formatting requirements that seem to be eluding me.  The final result should look like this:

[123|234|345|789|321|1|10|45|654|555
54|222|777]

There are three requirements coming into play:

  1. Result should be pipe delimited - I've successfully accomplished this with a new variable:
    1. {{varMyVariable.replace("], [","|")}}
  2. Result needs to be distinct - I've failed every way I've tried this.  I've tried the following:
    1. {{varMyVariable.distinct}}
    2. {{lookupIssues.customfield_xxxxx."My ID".distinct}}
  3. Result needs to split to a new line after every 10 matches

Appreciate any insights for this.  

1 answer

1 accepted

1 vote
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.
May 02, 2022

Hi Mark,

The distinct part...

The first attempt 

  1. {{varMyVariable.distinct}}

    This is not working because once you create a smart value-variable in Jira automation it turns it into a string, so it's not an array anymore, there for distinct will not work.

  2. {{lookupIssues.customfield_xxxxx."My ID".distinct}}

    What value did you get when this was run? This seems to be the correct syntax.

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2022

Thank you for the quick response @Garrett McCreery 

It still returns all values.  Here are the results of my sample issue where I'm still using distinct against the lookupIssues result (I've highlighted the dupes in bold):

[4068], [11909], [3594], [4517], [4248], [13452], [1908], [3883], [1], [1], [1], [1], [10], [10000], [10123], [10321], [10432], [10543], [10654], [10765], [10876], [10123], [10123], [10789], [10], [1], [1], [1]

Spent a couple hours on this one yesterday and just can't seem to get this one to play nice.

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.
May 03, 2022 • edited

@Mark Segall 

ok, I figured out how you can do this...

Take your result variable, and split it by commas with the distinct function...

insightObjectIDs.split(",").distinct

screenshot.png

Then you can use the replace method to get it back to the pipe separator.

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.
May 03, 2022

The split function turns it into an array (or "list") where the distinct function can be run!

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2022

Perfect!  That solves two of the three requirements.  Any chance you have any pearls of wisdom for creating a new line after each 10th result?

4068|11909|3594|4517|4248|13452|1908|3883|1|10
10000|10123|10321|10432|10543|10654|10765|10876|10789

Thank you again.

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.
May 03, 2022

I think the new line will depend on what application you are writing it out to. Where are you writing it to, a Jira field?

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2022

Yes - This goes to a Jira field

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.
May 03, 2022 • edited

Since Jira Automation does not have a real action/branch that can do looping, you would have to create a separate automation rule that can loop itself until you reach the end of the divisible by 10. It's more than I can show on the community chat. But I hope that helps.

I use the incoming web hook automation rule whereas I pass in the initial list, use substring, split, etc to get to the first 10, save that in a different array looking variable, remove the first 10, and call the incoming webhook (itself) with the original (minus the first 10) and the new variable. I will check to see if there are 10 items left before calling itself.

When there are less than 10 left is when I would write it out to a field.

Does that make sense?

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2022

This does make total sense and I was thinking that I may have to go the route of an additional rule to edit the field after the fact.  Thank you for all of your help on this.  I'm marking this as answered. 

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.
May 03, 2022

You are welcome and thank you!

Like Mark Segall likes this

Hello @Garrett McCreery ! I have what I believe is a similar type of a problem you helped solve for Mark with not being able to use the distinct to remove duplicates.

I have tried to figure out what you did here but have been unsuccessful thus far

Do you mind taking a look at my use case?

I've tried so many different things and am stumped

This is a great suggestion but it isn't working for me :( anyone know what I'm doing wrong?

customfield_12737 is a multi-select Assets field.image.pngimage.pngimage.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events