Automation on creating Epic (under issue) in advance X number of week from current date

Kaniawati Zainal Abidin March 26, 2024

Hi all,


Good evening to all. I am new with jira. Appreciate our community guidance as I need to make an automation to create a Epic for each future Sprint for X number of weeks ahead (eg. 4 weeks ahead). 


The Epic naming convention is "Sprint Week X" where X is the week number of the current year (eg currently today is 27 March so we are in Sprint Week 13.


Each sprint Epic is a duration of 2 weeks


- for year 2024, Starting 1 Jan 2024 (coincidently is a Monday) and end 14 Jan 2024 which is a Sunday as the 1st Epic which we named Sprint Week 1

- 15 Jan 2024 (Monday) till 28 Jan 2024(Sunday) as our 2nd Sprint in year 2024 which we named Sprint Week 3 

- whereby currently it is 27 March, so we are in Sprint Week 13 which started from 25 March (Monday) 2024 till 7 April 2024(Sunday)


So this automation i plan to run under the automation trigger "When:Scheduled" for every two weeks on a Monday and will create a new Sprint Epic 4 weeks ahead (eg. on 8 April morning, the automation will execute and create a new Sprint Week tittle of 4 weeks ahead with tittle "Sprint Week 19" which starts from 6 May till 19 May 2024).


This is what i had configured but not able to get the naming convention right (as i could get the current week of the year but not get the future week number). @Guy Anela i think the rule was not running even when i did the "run rule" force manually is either due to the JQL search (which i had removed asper screen short mock test VS the original i did as per screenshot schedule). But i did also specify the project as per your advice (did not use the original "same project").

Also to set the Epic start and End date, is there a more suitable/efficient Jira Smart Value feature than "{{now.plusDays(x)}}" as the 2 weeks i may not always "start on a Monday/end on following Sunday" during end of the month as the different number of days in a month.


Appreciate advice.


Thanks @Guy Anela @Jack Brickey  on the other thread. just knew how to create new thread for this specific query. Thankscreatre_epics schedule.jpgcreatre_epics schedule (mock test).jpgcreatre_epics overview.jpgcreatre_epics PlusWeek.jpgcreatre_epics Week4.jpgcreatre_epics WeekYear.jpgcreatre_epics View result.jpg

3 answers

2 accepted

1 vote
Answer accepted
Guy Anela April 1, 2024

Hi @Kaniawati Zainal Abidin - On your Create Issue Action, try something like this...



1 vote
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 28, 2024

Hello @Kaniawati Zainal Abidin 

Your first problem is that you have misunderstood what the functions do.

plusWeeks() returns a date/time, not the week number for the date you provided.

weekOfYear is not a valid function at all.

You can find the documentation for available functions related to date/time data here:


If you want to get the week number for the current date, you need an entirely different function.

If you look near the top of the page I referenced you'll find a table talking about built in formatting functions for date/time. The last entry in that table refers you to another document with the codes to allow you to create custom date/time formats.

From that document you will find that using the code "w" will give you the week of year for a date/time you supply:


If you want to modify that number and still have it be just a number, say add 2 weeks to it so that if the current week of year is 13 then the final number is 15, you would additionally convert the value to a number and then apply the "plus()" math function.


That is the type of smart value you should be using in the Summary field where you want to specify "Sprint Week #".


I'm still considering the other questions you raised in your post. I'll get back to you.

Kaniawati Zainal Abidin March 31, 2024

Thank you very much @Trudy Claspill this  "conversion" really helped with the Sprint naming and this give me hope that we can do automation with out the "rest API" which i'm trying very hard to able to understand using it :) . Very much appreciated on your simplicity solution.


I did not know that we could do the similar syntax (i only knew this is in SQL using "as" to represent something) "" and make the resutl into number value for math calculations. This worked so well for the Sprint/Epic tittle naming for 4 weeks ahead. TQVM

creatre_epics WeekAdd4.jpg


And now to make this automation work fully, i will need to use the automation scheduler as below that runs every two week, and the above automation will create a new epic/sprint that is 4 weeks ahead

creatre_epics runEvery2Week.jpg


The only gap i'm trying to find solution is on how to make sure the sprint/epic start day is always the Monday of the mention week and the due date is always the following  week of the Sunday (whereby each sprint/epic is a 2 weeks duration)

creatre_epics date.jpg

As in today example 1st April, i'm able to just add 28 days using


so the sprint Week 18 starts on 29 April and add another 41 days using


so the sprint ends on 12 May 2024, but this only works for the month having 30 days. 


creatre_epics WeekAdd4result.jpg


Any suggestion on how to make this automation work no matter how many days in the calendar month? I can only think of the logic having:

-  start date as 4 weeks ahead with the Monday as the date, and 

- due date as 5 weeks ahead with the Sunday as the date

But not sure how to configure/use what function in Jira automation. Saw the function "OfTheMonth" but saw the sample return of the day and not the date. Was not able to find (just guessing if there was) function "OfTheWeek".


Thanks in advance.




Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 1, 2024

Hello @Kaniawati Zainal Abidin 

To be clear, what you are doing with this automation is creating an issue. This automation is not actually creating a sprint.

And when you say you want to set the start and due dates, you are setting those for an issue, which is not the same as setting the Start and End dates of a sprint.

So, I'd like to confirm that it is your intention to be using the automation to create an issue, and not a sprint.

Guy Anela April 1, 2024

Hey @Trudy Claspill - I'll let @Kaniawati Zainal Abidin respond but wanted to give you some context. This stems from this original Community post...

Based on that, I believe Kaniawati does eventually want to create Sprints with the Automation but is simply testing with Epics just to get the Naming convention and Start/End Dates correct before diving into the API calls needed to make the Sprint. ...that's my guess. :) Again, I'll let Kaniawati confirm.


Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 1, 2024

@Kaniawati Zainal Abidin 

@Guy Anela provided an alternate answer concerning the test for the naming convention which made me think of other factors.

Your current goal for coming up with the name:

Sprint Week ##

This does not take into consideration that the week numbers will repeat from one year to the next when you choose to use a number that represents the week of the year.

If your process continues from one year to the next, you may end up with duplicated "Sprint Week ##" text strings.

If you are eventually going to use that information to name actual sprints, then you will end up with duplicated sprint names. While Jira will allow that, it is a bad practice. Your users may have trouble adding issues to the correct sprint and filtering based on sprints when duplicate sprint names exist. 

So, I would advise you to augment that text by denoting the current year also.


In addition, the answer I proposed did not consider the roll-over at the end of the year. If you were in week 51 (of 52) of the current year, my answer would give you a week number of 53. That would not be valid. In that regard, using something like plusWeeks() is a better method, though the use of "weekOfYear" is still not valid


Using plusWeeks() will properly return a date from the next year, if you are near the end of a year. Then using the format("w") function will give you the correct week number in the next year.


I still have to figured out an answer to your start on Monday / end on Sunday question.

Guy Anela April 2, 2024

Nice call out on adding the year to the Sprint Name, @Trudy Claspill Definitely a good idea. You could use something like this...

Sprint Week {{now.plusWeeks(4).weekOfYear}} of {{now.plusWeeks(4).year}}

Also, you mentioned a couple of times that the use of "weekOfYear" is not valid; I tested it with the above example and it appears to be working. I'm curious why you're saying it's not valid.

Here's the Rule I used to test it. It's simply a Scheduled Rule that I executed manually to log the values...


For the above test, I executed with a test date of December 23, 2024 to see if it would roll over to the next year correctly. Here's the entry in the Audit Log....


As you can see, it correctly rolled over to the next year with the correct WeekOfYear value as well as a Monday Start Date and Sunday End Date. 

Here's the Log entry I used to log the values...

SPRINT NAME: Sprint Week {{myDate.toDate.plusWeeks(4).weekOfYear}} of {{myDate.toDate.plusWeeks(4).year}}, START DATE: {{myDate.toDate.plusWeeks(4)}}, END DATE: {{myDate.toDate.plusWeeks(6).minusDays(1)}}

Again, those are using the {{myDate}} variable for testing purposes. To use the current date, you would replace "myDate.toDate" with "now"...

SPRINT NAME: Sprint Week {{now.plusWeeks(4).weekOfYear}} of {{now.plusWeeks(4).year}}, START DATE: {{now.plusWeeks(4)}}, END DATE: {{now.plusWeeks(6).minusDays(1)}}


Anyhow, I hope this helps. ...Cheers!

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 2, 2024

@Guy Anela 

I was wrong about weekOfYear. You were right.

When I tested it I was appending the asNumber function and getting no output.

Also the function description in the documentation doesn't seem to align with getting the week of the year back as the result, but rather describes it as a way to modify a date value to set it to another date based on the week of the year specified.

Kaniawati Zainal Abidin April 3, 2024

Hi @Trudy Claspill & @Guy Anela 


Thanks for the suggestion. Let me have a look at them when i return back to office tomorrow. 

Just for historical background, yes Guy's assumption was correct. During our early time with Jira, we were advice to create our Jira project for "flexibility" not to use sprint setup,  so it was not setup for "sprint" but if not mistaken chose the "kanban" option. But later after the creation (when we migrated all the details from excel to Jira), we needed to do the scheduler hence we used Epic in "issue type" to create the sprint Epic_issueType.jpg

and currently we are creating the "sprint" (under Epic) manually such as this Epic_sprint.jpg


Hence the suggestion to use Jira automation to create this whereby each "sprint" will be created 4 weeks in advance with a 2 weeks duration for each epic and the start date on the Monday & end date as per two weeks duration on a Sunday. 


Good point out to put in the year in the sprint name. I didnt noticed i missed it when trying to do the automation. Thanks for highlighting it. Previously when i manually do the create, i included the start date as per screenshot to differentiate each sprint/epic name. Reason was that in a glance by just reading the Epic name, instantly will know which week of the year & when actually it starts.


Let me try tomorrow in my testbed on the suggestion. 

Kaniawati Zainal Abidin April 5, 2024

Hi @Trudy Claspill & @Guy Anela 


To get the start date included in the title (as per current "manual epic/sprint creation naming convention), I have updated the "Summary" with

Sprint Week {{now.plusWeeks(4).weekOfYear}} ( {{now.plusWeeks(4).format("dd MMM YYYY")}})

So as example when i execute it today, i will get the Epic tittle name as below screenshot (identical with current :)).


Which the actual Start Date & Due Date will actually be correct if i run this automation on the Monday so the Start Date will be on Monday 29 April 2024 and Due Date will fall on  Sunday12 May 2024. (compared now it start on Friday date and end on Thursday date)


So just make this automation not depending on the day of when it is executed so that the start day always to start on the monday of the week & end on the Sunday of the following week, can i use jira smart value "startOfWeek" or "endOfWeek(-1d)"? 


I tried useing below:





But seems not working. Got empty return for the date part. I suspect i got my syntax wrong? can advise.


Thanks a million in advance.


Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 5, 2024

"startOfWeek" and "endOfWeek" don't appear in the documentation of functions that can be used with a date/time value.

I tried to use the {{<date>.withDayOfWeek("MON")}} to get the date for Monday in the week represented by the <date> value, but that didn't work. I also tried:



All returned no value.


The next thing I looked at was figuring out which day of the week a given date is. That can be done with this command:


That gives you a number for the day of the week for the specified date. For instance in my system on a Friday if I use {{now.format("e")}} I get the value 6.

You could figure out the date for a specific day of week using that with an IF-Else block and creating a variable. There might be a simpler way to do this, but this way did seem to work.

Screenshot 2024-04-05 at 1.37.53 AM.pngScreenshot 2024-04-05 at 1.39.27 AM.png


Kaniawati Zainal Abidin April 5, 2024

Thanks @Trudy Claspill 


Just to reconfirm, when you mentionyour system on is currently a Friday ad when use {{now.format("e")}} , you get the value 6? so does this means the system default is zero (1) is a Sunday?

So your suggestion approach is to use the system defined in {{now.format("e")}} to do a customized IF statement which define:

1 - Sunday

2- Monday

3 - Tuesday

4 - Wednesday

5- Thursday

6 - Friday

7 - Saturday


But there will alway be no value whereby {{now.format("e")}} equals 0. This i do not understand the 1st IF rule and only understand all the scenario will go to the else.


Can you help share on how the setting configuration looks like. 



 some clueless how/where value i need to put in

Epic_createVariableConfig1.jpgEpic_createVariableConfig2.jpgi dont understand why just need to define Monday but not the other days?

Epic_createVariableConfig3.jpgand not sure how for this and the remaining.



Guy Anela April 5, 2024

@Kaniawati Zainal Abidin If the Automation is only going to be executed Mon-Fri, you could use something like this...

START DATE: {{now.plusWeeks(3).withNextDayOfWeek("MON")}}
END DATE: {{now.plusWeeks(5).withNextDayOfWeek("SUN")}}


I simply decreased plusWeeks by 1 (so the start date went from +4 weeks to +3 weeks and the end date from +6 to +5). Then I added the withNextDayOfWeek so it will add the additional week.

I did two separate tests by executing it with a Monday date (04/01/2024) and a Friday date (04/05/2024), and both returned a Start Date of 4/29/2024 and End Date of 5/12/2024.

Again, this ONLY works if you execute on a Mon-Fri. If the Automation is going to execute on Sunday or Saturday, then the above will not work. You'll need to add IF/Then logic as Trudy suggested.

Again, I hope this helps. Cheers!


Kaniawati Zainal Abidin April 7, 2024

Thanks @Guy Anela 

Yes, the automation is activated/started on a Monday.

I understand and find it logic when we lesser one week to get the Monday day when use {{now.plusWeeks(3).withNextDayOfWeek("MON")}} . The 1st April 2024 result make sense.

I just want to understand for minus one week when use {{now.plusWeeks(5).withNextDayOfWeek("SUN")}} on the Friday sample. Can i conclude when we use withNextDayOfWeek , the "week" definition is from the start of the automation (in this sample middle of the week 5th April 2024) till 11the April 2024 (as per circle in green in below screenshot)? Coz i can only get to understand this is the logic when we able to get12 May 2024 as the due date.


As if the "week" definition for 5th April 2024 is the normal week date from 31st March till 6th April 2024 (as read somewhere Jira start week is a Sunday as per box in yellow in above screenshot)). I count manually the five week & will get 5th May 2024 "Next Sunday"...


Thanks in advance for the help.



Guy Anela April 8, 2024

Hey @Kaniawati Zainal Abidin - The withNextDayOfWeek is tacked on after the plusWeeks causing it to go into the 4th week (for the Start Date) and the 6th week (for the End Date). Here's an illustration that might help...


0 votes
Kaniawati Zainal Abidin March 26, 2024

sorry, seems the screenshot was not attached when i thought i had inserted earlier (which i had not as did not press the button) for reference. Here it is. sorry for the inconvenience

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events