Jira Automation - Create Sub-Tasks

Sarah Chapman
Contributor
September 1, 2022

Hello, 

I am using Jira Automation to try to create monthly tasks to split out and manage our regular BAU Reporting. I have managed to automatically create tasks and sub-tasks on the first of every month successfully using the rules below. 

Jira.PNG

 

However I am looking to create a task for the first of the month, then create subtasks in advance on a weekly basis for each Monday within that month which are labelled dynamically with the date in the Summary field See example below. 

  • Task - 'BAU Reports - Sep 2022' -> JQL {{now.format("MMM-YYYY")}}
  • Sub-task ' BAU Reports - 5th September 2022' 
  • Sub-task ' BAU Reports - 12th September 2022'
  • Sub-task ' BAU Reports - 19th September 2022'
  • Sub-task ' BAU Reports - 26th September 2022'

Does the community have any ideas how on this can be done and if this is possible just using Jira Automation? 

Many thanks,

Sarah 

 

2 answers

1 accepted

2 votes
Answer accepted
Sarah Chapman
Contributor
September 2, 2022

Solution 

Sarah Chapman
Contributor
September 2, 2022

Solution to create a monthly task and sub-tasks for every week starting on monday with dynamic dates: 

  • Scheduled: 1st day of the month
  • Action: Create a New Task
    • Ticket Summary: {{now.format("MMM-YYYY")}}
  • Branch (Branch Rule Created): For Most Recently Created New Issue
  • Action: Create Sub-tasks 
    • {{now.withNextDayOfWeek("MON").plusWeeks(0).format("dd/MM/yy")}}
    • {{now.withNextDayOfWeek("MON").plusWeeks(1).format("dd/MM/yy")}}
    • {{now.withNextDayOfWeek("MON").plusWeeks(2).format("dd/MM/yy")}}
    • {{now.withNextDayOfWeek("MON").plusWeeks(3).format("dd/MM/yy")}
  • Condition: If Compare two value. 
    • {{now.diff(now.endofmonth).weeks}} equals 5
  • Action: Create Sub-task
    • {{now.withNextDayOfWeek("MON").plusWeeks(3).format("dd/MM/yy")}

The same concept can be applied for creating subtasks for each day of the month by changing the code to

  • {{now.plusDays(0).format("dd/MM/yy")}}
  • {{now.diff(now.endofmonth).days}} with conditions to say if equals 29 create 1 extra subtask, equals 30 2 extra subtasks. 

Jira3.PNG

Hope this is helpful to others!

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.
September 2, 2022

Nice approach!

3 votes
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.
September 1, 2022

Hi @Sarah Chapman - You'll want two automation rules:

Automation 1: Task Creation

  • TRIGGER (Scheduled): 1st Day of every month
  • Create Task

Automation 2: Sub-Task Creation

  • TRIGGER (Scheduled): Every Monday
  • ACTION: Lookup Issues
    • Summary ~ "'BAU Reports*" AND created >= startOfMonth() AND created < startOfMonth(1d)
  • ACTION: Create Issue
    • Issue Type = Sub-Task
    • Parent = {{lookupIssues}}
    • Summary = BAU Reports - {{now.("d MMMM YYYY")}}
      • NOTE - If you want exact formatting of 1st, 2nd, 3rd, etc., you'll need some If/Else conditions and variables which will make the rule a bit more complex.
Sarah Chapman
Contributor
September 1, 2022

Hi @Mark Segall

Thanks for this. This has worked really well.

However for the sub-tasks I am trying to dynamically label/create a ticket for every Monday within a given month as that's when our regular reports are run. 

I have managed to use the following smart values to generate a dynamic naming convention within the ticket summary for the subtasks  

{{now.withNextDayOfWeek("MON").plusWeeks(0).format("dd/MM/yy")}}

however by doing this we may get tickets created for the next month, under September's tasks due to the variations of Mondays in the given month so in some cases there will be 4 subtasks or 5 subtasks. Hope this makes some sort of sense. Apologies if this is not clear. 

Like John Funk likes this
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.
September 1, 2022

Ahh sorry about the misunderstanding.  I understand now.  So you want to just auto-generate all sub-tasks upfront for a given month as the parent task is created?  You could do something like this:

  • TRIGGER (Scheduled): 1st of every month
  • ACTION: Create Task
  • ACTION: Create Variable 
    • varWeeks
    • {{now.diff(now.lastOfTheMonth(1).weeks)}}
  • BRANCH (Advanced): {{varWeeks}}
    • Create Sub-Task

I haven't tried this myself yet, but I think this will work.

Like Sarah Chapman likes this
Sarah Chapman
Contributor
September 1, 2022

Hi @Mark Segall

Really appreciate your help on this. I have got to the branching stage and slightly confused on the next steps for creating the sub-tasks using the variable? Would you be able to provide some additional guidance? Apologies if this quite trivial. 

 

Jira2.PNG

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.
September 1, 2022

You may not need the variable.  You could just do this for the branch:

  • Smart Value = {{now.diff(now.lastOfTheMonth(1).weeks)}}
  • Variable = varWeeks

Then as you create each subtask, you'll have a summary like this:

{{now.withNextDayOfWeek("MON").plusWeeks(varWeeks).format("dd/MM/yy")}}

This may require a bit of trial and error, but it theoretically should work. 

Like Sarah Chapman likes this
Sarah Chapman
Contributor
September 2, 2022

Thanks @Mark Segall. After some trial and error managed to get it to work. Will post the solution below. 

Like Mark Segall likes this
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.
September 2, 2022

That's great!  Yes, I'd love to see how it ultimately worked for you.

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