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:
{{lookupIssues.customfield_xxxxx."My ID"}}
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:
{{varMyVariable.replace("], [","|")}}
{{varMyVariable.distinct}}
{{lookupIssues.customfield_xxxxx."My ID".distinct}}
Appreciate any insights for this.
Hi Mark,
The distinct part...
The first attempt
{{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.
{{lookupIssues.customfield_xxxxx."My ID".distinct}}
What value did you get when this was run? This seems to be the correct syntax.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Then you can use the replace method to get it back to the pipe separator.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The split function turns it into an array (or "list") where the distinct function can be run!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes - This goes to a Jira field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome and thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.