Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Ability to iterate / loop an JIRA automation rule to create N number of sub-tasks

Nuwanee Nadeesha November 11, 2022

Hi Experts!

I'm currently trying to create a rule using JIRA service management automation to create an N number of subtasks when an issue transitions from one state to another.

My problem is as follows:

  • My trigger issue has two date fields: Start Date and End date
  • If the difference between the Start Date and the End date is considered as N number of business days;
  • Then I need to create N number of subtasks under the trigger issue; one sub-task per each business day. 

Is there a way to create a number of subtasks dynamically based on a value defined in any custom field/variable?

Any help, advice, direction would be greatly appreciated please?

 

4 answers

2 accepted

1 vote
Answer accepted
Alex Koxaras _Relational_
Community Champion
November 12, 2022

Hi @Nuwanee Nadeesha 

There isn't a simple way to do what you want. The only feature that Atlassian provides us with Jira Automation is to "branch" using a custom variable list. And this has to be a list!

With that said the only list I can think of and could do that trick for you is a multi select checkbox. In theory this should work:

  • Create a checkbox field with XX values (let's hope that you will not need more that 30-31)
  • Create a rule
  • Calculate the date difference you want (hopefully less that 30-31)
  • Using If/Else pass the difference to the CF
    • if you have e.g. a diff of 10 days, then ALL values from 1 to 10 must be selected
  • Once you done this branch using a custom variable
  • As a list, you place the values of the above field
  • As an internal component you place a create subtask under the trigger issue

It's not the best approach, but it's the only thing you've currently got. I would recommend getting an app like JMWE and do everything from there. Better :)

Nuwanee Nadeesha November 13, 2022

Hi @Alex Koxaras _Relational_

Thanks for the valuable feedback, I'll try out your workaround and hopefully revert with some results.

1 vote
Answer accepted
Kian Stack Mumo Systems
Community Champion
November 11, 2022

@Nuwanee Nadeesha

 

I'm not sure what the best way to do this would be/if it is possible. I took a look at a few different options to see what if anything can be done. In order to iterate a dynamic number of times, you would need to use the advanced branching. One thing you could try to do is find an API endpoint which returns a list of each business date between the start and end date custom fields. You could iterate over that response and tell if to create a new subtask for each business date returned. I haven't found an API like that, but one may exist that you could leverage.

 

You can get the total number of business days using this smart value - {{now.diff(issue.created).businessDays}}, but that doesn't give you anything to iterate over.

Kian Stack Mumo Systems
Community Champion
November 11, 2022

There is an open feature request to iterate a number of times based on a custom field, but that hasn't been picked up yet. 

Like Nuwanee Nadeesha likes this
Nuwanee Nadeesha November 13, 2022

Hi @Kian Stack Mumo Systems

Thanks for the valuable feedback and details.

1 vote
Payden Pringle
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 8, 2023

Greetings Nuwanee,

I have recently released a Community Article specific to your issue, so I thought it'd be helpful to share it here.

How to create dynamic looping in Automation for Jira

I hope this helps.

Take Care,
Payden Pringle
Atlassian Support

Jawann Swislow
Contributor
December 7, 2023

This is the way. Worked perfectly for me.

Like Payden Pringle likes this
0 votes
Amanda Culver April 17, 2025

Create the variable with this smart value 

Variable name : Number_of_days_til_THE_END
Smart Value : {{#=}} {{now.diff(issue.dueDate).days}} {{/}}

 

Suggest an answer

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

Atlassian Community Events