I have an automation where I am trying to run the automation this week, but I want the created story to have a start date of next week's Wednesday and a due date of next week's Friday. Here is what I am using:
Start Date (this is a custom field):
{{now.withDayOfWeek(3).plusWeeks(1)}}
Due Date:
{{now.withDayOfWeek(4).plusWeeks(1)}}
I have also tried {{now.plusWeeks(1).withDayOfWeek(4).jiraDate}} and each time the start and due date get returned empty.
Any suggestions are appreciated!:)
Hello @Ganea_ Merissa
I don't have an answer for you yet on the correct way to do this, but I can tell you why it isn't working as you currently have it.
According to the documentation there is no such function as withDayOfWeek().
EDIT: I was wrong. The function does exist.
I must retract my last statement. I found it buried in the documentation:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I came up with a solution. It may not be the only solution.
You can use two IF/ELSE blocks to assess what the current day of the week is and from that get the date for the specified day of the week in the next week.
This smart value returns the number for the current day of the week:
{{now.format("e")}}
In my system the week is set to start on Sunday, and the numbers associated with the days of the week are 1 through 7.
The logic for getting the date for Wednesday of next week is then:
If the current day of the week is Weds or later
Then get the date of the next Weds
Else
Add one week to the current date, and then change that date to the Wednesday of that week.
In my example I am using just a Log action to print the results to the rule execution Audit log.
You would use a similar IF/ELSE block to get the date for the Friday of next week.
The tricky part is how to incorporate this into your current automation. And the answer depends on the structure of your current automation.
Is you automation creating the Story that you want to change, or is it triggered by the creation or or a change to the Story you want to change?
Can you provide a screen image showing your entire current automation rule?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the correct syntax for embedding this within a field.
Using Wednesday as the example day of week:
{{if(now.format("e").asNumber.gt(3), now.withNextDayOfWeek("WED"), now.plusWeeks(1).withNextDayOfWeek("WED"))}}
You can use this in a Create action. I used it in an Edit action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I recommend adding .jiraDate to the end of each expression to ensure the time component of the value does not cause problems with the Due Date field. I have both observed and read questions where that can intermittently cause problems for date-only fields versus date / time ones.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Bill Sheboy
I just published an article on this solution. I welcome this and any other feedback that you would like to share.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With @Bill Sheboy suggestion the final syntax is:
{{if(now.format("e").asNumber.gt(3), now.withNextDayOfWeek("WED").jiraDate, now.plusWeeks(1).withNextDayOfWeek("WED").jiraDate)}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ganea_ Merissa
Could you please share a screenshot of the full automation, ensuring any sensitive data is hidden? Even seemingly small detail can lead to Failure. Before that it will be hard for us to Doctor 💊 your Automation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I used the below workaround, but my fear is if automation ever fails and the fix doesn't happen until the next day, then all of my dates will be wrong. I really want to be able to specify the next week's day of the week for both the start and due date. This pertains to accounting information and any wrong date could mean a payroll delay.
| {{now.plusDays(5)}} to get Monday | {{now.plusDays(7)}} to get Wednesday |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ganea_ Merissa
What you showed doesn't match your original requirement:
start date of next week's Wednesday and
a due date of next week's Friday.
With your rule scheduled to run on Wednesday your start date current is set to
Weds + 5 days = next Monday
And your due date currently is set to
Weds + 7 days = next Weds.
Also what do you mean exactly by "if it fails and doesn't get fixed until the next day"? Do you meany you would manually run the rule on a different day of the week than the scheduled run on Weds?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are two automations...the other one would use this for both the due date and the start date: {{now.plusDays(9)}} to get a due and start date of Friday.
What I mean by if it fails and doesn't get fixed until the next day is this: If Jira automations fail due to an outage and the fix doesn't get implemented until Thursday, sometimes Atlassian runs all failed automations that happened during that time. If they did that, then the start and due date would get pushed out by a day...no longer landing on the Friday it was due, because it is counting out days from the date the automation got run instead of specifying the actual day of the week to be due.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The method I proposed in my answer would set the dates correctly regardless of which day of the week the automation runs.
But my method is not able to be used directly within the fields.
What is the configuration of your Scheduled trigger? Does it include a JQL such that multiple Stories end up getting created each time it runs? Or is the intention to create just a single story each time it runs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
multiple stories get created each time it runs, and each story could have a variation of two start and due dates: Monday to Wednesday, or Friday to Friday. For this one automation formula, 200+ stories rely on it to have accurate dates. I need the jql to be within the fields.
I have a separate automation that then checks the start and due dates after they have been populated to ensure they do not fall on a company holiday. If they do, then the separate automation would move the dates to the preceding business day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.