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
Community Members
Community Events
Community Groups

Loop over first X issues

We're setting up an automation which fires when a ticket is transitioned to closed. We then want to transition another ticket to In progress. The problem we're looking into is that there's no way (that we've found) to limit how many tickets you loop over. We're using this to get the issues:

- Use "For JQL" to lookup issues (in our case: status = "Pending" AND reporter = {{issue.reporter.accountId}} AND project={{issue.project.key}} order by created)

- We want to transition one of the resulting issues from this to In Progress.

The problem could be solved if one of the following was available:

- Condition/Variable that lets you look at which result number in the for loop you're on (I understand that they run in parallel, but you could still have a variable that tells you the position of the result)

- In the For JQL lookup, add a way to limit the results to a specific number. It limits it to 100, but there's no way to lower that limit.

1 answer

0 votes
Hana Kučerová Community Leader Nov 16, 2020

Hi @jctenney ,

welcome to the Atlassian Community!

I've been thinking about this and to be honest, I don't see any clean way of doing it.

Maybe if you share more information about your use case, we will be able to find any other way how to do it.

We basically only allow a single issue by reporter that can be in In Progress at a time. When one is closed, we need to grab the oldest issue (that is Pending) for the same reporter and move it to In Progress. 

Thank you.

The only possible way I can see is to create custom groovy script, but you would need some additional application for it, this situation is too much specific.

Yeah - we're actually on the cloud version, but custom variables don't solve the problem as for loops don't share the updates across them. In other words, if I change the value of a variable in one of the loop actions, the other loops don't see those updates. That's because it's not actually a for loop, but more like a fork of the process. Is there a place I can create a feature request for Jira Automation in the Cloud? I'm not seeing an obvious project for that type of request.

I've already resorted to using Scriptrunner to do what we need. We were so close on Jira Automation though and would have been nicer to have it there than in code.

Hana Kučerová Community Leader Nov 17, 2020

Yes, sorry, I realized it too late that you are on cloud (probably the codebarrel tag confused me).

I think the best place is Jira Cloud (including JIRA Core) + component Automation for Jira.

Suggest an answer

Log in or Sign up to answer
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:...

389 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