Need help with scheduling in automation to create an issue on 2 weekdays before last weekday of mont

Abhilasha Tyagi
Contributor
October 17, 2024

First, I want to create an issue automatically with a schedule trigger every 2 business days prior to last business day of the month.

Second, to create an issue on 2 business days prior to first business day of month. 

I have thought and tried a lot but no idea how to go about it. Smart values like {{LW.minusbusinessdays(2)}} or any other smart values are throwing error in cron expression. I believe it is not allowed there.

Any assistance would be of great help. Thanks.

1 answer

1 accepted

3 votes
Answer accepted
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.
October 17, 2024

Hi @Abhilasha Tyagi and welcome to the community!

There is no explicit way to capture this as a cron that I'm aware of. However, you could go this route:

  • TRIGGER: Scheduled (Daily)
  • CONDITION (Smart Value)
    • {{now.startOfDay}}
      Equals
      {{now.startOfDay.endOfMonth.minusBusinessDays(2)}}
  • ACTION: Create Issue

This will execute daily and check to see if the current run time is 2 business days before the end of the month. If the condition passes, create the issue, otherwise exit.

Abhilasha Tyagi
Contributor
October 17, 2024

Thanks for your response. now.startOfDay.endOfMonth - what does this return? Is this same as last business day of the month?

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.
October 17, 2024

So what should be happening is that it's validating whether the execution start of day matches the start of day for 2 business days before the end of month.

Bill Sheboy
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.
October 17, 2024

Greetings!

Adding to Mark's suggestions, please review the documentation for the automation date / time functions to understand their behavior:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

Kind regards,
Bill

Abhilasha Tyagi
Contributor
October 17, 2024

@ Mark, Since I am interested in 2 business days prior to last business day of month besides 2 days before last day of month,  can I edit the condition parameter as 

  • {{now.startOfDay}}
    Equals
    {{now.startOfDay.lastBusinessDayOfMonth.minusBusinessDays(2)}}
Abhilasha Tyagi
Contributor
October 17, 2024

this is what it looks like ..do you think this will work.Asking for validation coz there is no way I can test it until this EOM. If condition.png

Bill Sheboy
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.
October 17, 2024

You can test almost anything in rules immediately, as follows:

  • action: create a variable with the date value to use, instead of {{now}}
    • name: varMyDate
    • smart value: 2026-10-05
  • convert that to a date to use in your expression with toDate:
    • {{varMyDate.toDate}}
  • test your rule until it works as expected
  • edit your rule to replace with the dates needed, such as {{now}}

 

When I test for several cases in scenarios like this, I create a list of dates, and iterate over them to test:

  • action: create variable
    • name: varListOfDates
    • smart value: 2024-01-01,2024-01-31,2024-02-01
  • advanced branch:
    • name: varADate
    • smart value: {{varListOfDates.split(",")}}
      • test each value for {{varADate.toDate}}

 

Abhilasha Tyagi
Contributor
October 17, 2024

Really appreciate your help, Bill. 

The test run is working as expected for 1 case only. When {{now}} is replaced by another variable with value 2024-10-29 the  issue got created. However it is not giving desired results with date variable set to 2024-11-27 (i.e issue should have been created as 27th Nov is 2 days before last working day (29) in Nov.

What is going wrong now?

Bill Sheboy
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.
October 17, 2024

Please post an image of your complete test rule, the action where the date change is happening, and the audit log details showing the rule execution.  Thanks!

Abhilasha Tyagi
Contributor
October 17, 2024

here when date is date in October, issue gets created correctly. oct rule audit.PNGoct rule.PNGoct rule audit.PNG

Abhilasha Tyagi
Contributor
October 17, 2024

But when variable date is set in November, the if condition does not pass and issue is not created.

Nov rule audit.PNGNov rule.PNG

Bill Sheboy
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.
October 17, 2024

Isn't the last business day (i.e. Monday-Friday) of November 2025 the 28th, not the 27th?  And so your test day should be the 26th.

Rather than create issues in testing, I recommend using the list method I described and just writing both dates to the audit log.  That will reduce cleanup after testing.

 

Abhilasha Tyagi
Contributor
October 17, 2024

I am testing for 2024 not 2025.

Bill Sheboy
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.
October 17, 2024

Your test dates shown in the create variable images are both for 2025.  Please change them and re-test.

Abhilasha Tyagi
Contributor
October 17, 2024

Good Catch. Thanks .Its working.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events