Iterating through elements in a generated smart values list

Dd February 9, 2023

Hi,

Say I generated a smart value list from a JQL ListOfNames which is {{lookupissues.MyNames.distinct}}.

How can I now iterate over this list using a smart value SomeName and use that value each time in a JQL query?

Thanks

1 answer

1 accepted

1 vote
Answer accepted
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 9, 2023

@Dd

 

I'm not seeing a great way to do this. What are you trying to accomplish?

Thanks,

Kian

Dd February 10, 2023

What I'm trying to achieve is as follows:

Say I have open tickets that can be related to CARs. Cars is a Custom field and I have different models.

I would like automation to run a JQL of all the open tickets.

Go through the lookup list and pickup all the distinct car models in open tickets.

Then loop over the list of distinct models.

For each:

  • Run a JQL and get a lookup list of all the open tickets for that model.
  • If the size of the list is over a predefined number - send an email

Does that make it clearer?

Thanks    

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 10, 2023

Thanks @Dd

 

I was able to get something to work!

 

The general configuration looks like this:

 

Screen Shot 2023-02-10 at 9.41.57 AM.png

  1. Perform the lookup
  2. Do an "Advanced branching" with the smart value set to "{{lookupIssues.cars.value.join(",").remove("[").remove("]").replace(", ",",").split(",").distinct}}" and the variable name set to Cars
  3. Perform a lookup of issues with the JQL cars in ({{car}})
  4. Write an advanced If condition. {{lookupIssues.size}} > [YOUR CUTOFF]
  5. Send the email!
Dd February 11, 2023

This looks awesome. I'll try it!

Question though - I assume (based on what you wrote) that there's a way to see the actual output of a smart value. Where can I read how to do that?

Thanks

Dd February 11, 2023

I'm probably doing something wrong as my JQL fails

I probably don't use the smart values properly.
I'll try Sunday, and if it fails - I'll upload my attempt

Dd February 12, 2023

I'm doing something wrong. To be honest, I'm not sure what cars refers to in your example.
In any case, below is a snapshot of what I wrote 
Smartvalues1.JPG

I also had a version with a JQL

Smartvalues1.1.JPG

th don't work (the JQL won't even be verified).
Obviously I'm doing something wrong :-(

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 12, 2023

"Cars" was just a custom field I created to have the different car models!

Dd February 13, 2023

I figured that one out eventually :-)
But as u can see above - I can't get that to work. 

Any ideas?

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

What is the value in your smart value {{failedBranch}}?

Dd February 13, 2023

I cannot see it.
I tried using the add log with {{#debug}} in front and it wouldn't accept that

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

Add a new action of the type "Log Action". Add the smart value in there and rerun your rule.

Dd February 13, 2023

I did, and it failed - I'll try again

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

That is expected! You need to go into the audit log and see what was logged.

Dd February 13, 2023

It just logs {{FailedBranch}} with no content.
Should I plug in the {{#debug}} in fromn?

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

No, that won't do anything. Can you share a screenshot of the branching you are trying to do?

Dd February 13, 2023

I do get a failure later on 

Custom Smart Value JQL Search: "("Failed in Branch[Dropdown]" in ()) AND (project in (10002))" - Error in JQL Query: Expecting either a value, list or function but got ')'. You must surround ')' in quotation marks to use it as a value. (line 1, character 35)

in () looks like the {{FailedBranch}} is empty 

Dd February 13, 2023

{{lookupIssues."Failed in Branch[Dropdown]".value.join(",").remove("[").remove("]").replace(", ",",").split(",").distinct}}

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

Is the actual field called "Failed in Branch[Dropdown]"? Or is Dropdown the type?

Dd February 13, 2023

Dropdown is indeed the type but that's the way it appears in the JQL.
I have it in an initial JQL and it works fine with that Dropdown

At the start I'm executing "Failed in Branch[Dropdown]" is not EMPTY and I get the correct lookup list

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

Get rid of it in the smart value. Try it like this -

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

Like Dd likes this
Dd February 13, 2023

OK.
That made some progress.
Let me try and play with it tonite and see if I get anywhere.
I'll update tomorrow.
Thanks

Like Kian Stack Mumo Systems likes this
Dd February 13, 2023

So now I get the correct list in FailedBranch. (BRANCH_2)
How do I loop over the values in FailedBranch and for each run the JQL filtered to that value and then check the size?
 
Doesn't seem like "Failed in Branch[Dropdown]" in ({{FailedBranch}}) does the trick

Dd February 13, 2023

I figured out what I did wrong - it's working!
Thanks

Like Kian Stack Mumo Systems likes this
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

Excellent! What was the issue?

Dd February 13, 2023

Once you resolved the issue of getting the log action to work, I could see the actual parameter extracted from the list. Then it was clear I was missing quotation marks on the value when filtering since I had a space in it.
 

Now it works perfect!

Like Kian Stack Mumo Systems likes this
Dd February 13, 2023

I'll ask one last semi-related question - when I send the email - is there a way to send the issues from the lookupissues list as hyperlinks and not just ticket keys?

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

Put this in the body of the email:

 

{{#lookupIssues}}
{{url}}
{{/}}

Like Dd likes this
Dd February 13, 2023

Worked like charm!
Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events