Set Start Date and Due Date based on Quarter in Summary

Adam Channing February 16, 2023

Hi all

I've scoured the source material and google - it's been several hours and I can't get this to work.

I want to automatically set the start and due date to the beginning and end of a quarter based on the summary string.

For example, "Q3 Reviews" would set the start date for July 1st and end date for Sept 30th.

The IF condition is working fine, but my code is failing to update the start and due date. The audit log states the rules ran successfully and edited the issue.

Start date:

{{#switch}}{{issue.summary.match('Q1') ? now.format('YYYY') + '-03-31'}}{{issue.summary.match('Q2') ? now.format('YYYY') + '-06-30'}}{{issue.summary.match('Q3') ? now.format('YYYY') + '-09-30'}}{{issue.summary.match('Q4') ? now.format('YYYY') + '-12-31'}}{{/switch}}

Due Date:

{{#switch}}{{issue.summary.match('Q1') ? now.format('YYYY') + '-06-30'}}{{issue.summary.match('Q2') ? now.format('YYYY') + '-09-30'}}{{issue.summary.match('Q3') ? now.format('YYYY') + '-12-31'}}{{issue.summary.match('Q4') ? (now.format('YYYY') + 1) + '-03-31'}}{{/switch}}

 

I have also tried using wildcards e.g. "issue.summary.match('Q1.*')"

 

Can anyone point me in the right direction?

3 answers

1 accepted

1 vote
Answer accepted
Adam Channing February 26, 2023

Okay I eventually figured out the correct JQL and smart values to use to get this right. So the condition for checking if the issue created date is after the first day of March (current year) is:

 

{{issue.created >= (now.withMonthOfYear(3).startOfMonth())}}

 

So to check whether a task created should be assigned to this years quarter (e.g. Q1) or next years based on the created date now works! :)

 

Capture.PNG

1 vote
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2023

Hi @Adam Channing

Welcome to Atlassian community!

This is what I did when creating the automation rule:

  • Select the trigger as 'Issue created'
  • Checking if the issue type is of specific one, in this case 'Bug'
  • Added 'if / else block'
    • Added the 'Issue fields condition' 
    • Selected 'Summary' for 'Field'
    • Select 'contains' for 'Condition'
    • Entered 'Q1' for 'Value'
  • Selected the 'Edit issue' as 'New action' component
    • Selected 'Start Date' and entered '{{now.withMonth(3).endOfMonth}}'
    • Selected 'Due Date' and entered '{{now.withMonth(6).endOfMonth}}'
  • Repeated the process for Q2, Q3 and Q4.
  • Q2
    • Start Date - {{now.withMonth(6).endOfMonth}}
    • Due Date - {{now.withMonth(9).endOfMonth}}
  • Q3
    • Start Date - {{now.withMonth(9).endOfMonth}}
    • Due Date - {{now.withMonth(12).endOfMonth}}
  • Q4
    • Start Date - {{now.withMonth(12).endOfMonth}}
    • Due Date - {{now.plusYears(1).withMonth(3).endOfMonth}}

I am enclosing the screenshot for your reference.

Hope this helps.

Thanks,
Vamsi

Screenshot 2023-02-16 114237.png

Adam Channing February 16, 2023

Thanks so much!

Thats working perfectly! I'm experimenting now with trying to add conditions to check if the quarter variable is in the future, and if so move the start and due dates to next year.

So far it's setting all of my dates to next year to I havent quite figured that part out yet!!

Capture.PNG

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2023

Hi @Adam Channing

Glad that it worked out.

Good to know that you are trying to enhance the logic.  Sorry, I did not quite follow the condition based on your automation rule screenshot.

If you don't mind, can you provide a brief example about what you are looking for so that I can provide you a solution?

Thanks,
Vamsi

Adam Channing February 17, 2023

Thanks!

So in trying to set the start/due date according to the quarter in the title, e.g. Q2, I also want to set a condition to check if the current date is after the end of Q2. 

But even though we havent reached Q2 yet, the issue is still setting the start/due dates to next year. 

 

 

If Block:

Issue Fields Condition:

Summary contains Q2

and

JQL condition 

{{issue.created >= now.withMonth(6).endOfMonth()}}

Then

Edit Issue Fields:

Start date

{{issue.created >= now.withMonth(6).endOfMonth()}}

Due date

{{issue.created >= now.withMonth(6).endOfMonth()}}

Else

Issue Fields Condition:

Summary contains Q2

Then

  • Start Date - {{now.withMonth(6).endOfMonth}}
  • Due Date - {{now.withMonth(9).endOfMonth}}
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2023

Hi @Adam Channing

To be clear, let me clarify this.

Supposing the ticket was created on July 14th 2023.  This falls in Q2 and is between the dates 06/30/2023 and 09/30/2023.

So, since Q2 already started for this year, you want to set the Start Date and Due Date for this ticket as 06/30/2024 and 09/30/2024 respectively.  Am I correct?

Or, like we are in Q4 now.  So, any ticket that gets created today will have the Start Date as 12/31/2023 and Due Date as 03/31/2024?

Thanks,
Vamsi

Adam Channing February 20, 2023

Thats exactly it! :)

My GRC tool sends tasks to Jira as soon as the old one is done, so quarterly scheduled tasks appear in the same period if I dont check for this.

Even so, I still want to keep the flexibility of scheduling new tasks for a given quartner and not have them automatically get assigned to next year. Hence my struggle! 

Thank you so much for you help!

0 votes
Sowmiya November 14, 2024

Hi

Is it possible to set Quarters automatically(Q1, Q2, Q3, Q4) based on due date present in the ticket?

Thanks

Suggest an answer

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

Atlassian Community Events