Trying to add hours to a custom date/time field and it doesn't update as expected. I suspect it is some kind of timezone issue? I'm using Jira Cloud.
Example 1 - worked as expected
Formula: {{now.plusBusinessHours(1)}}
I triggered automation on Aug 4 at 8:16 am PDT and after the automation runs the custom date/time was set to "Aug 04, 2021, 9:16 AM"
Example 2 - not working
Formula: {{now.plusBusinessHours(4)}}
I triggered automation on Aug 4 at 8:18 am PDT and after the automation runs the custom date/time was set to "Aug 05, 2021, 3:18 AM"
I'm using info from this article: https://community.atlassian.com/t5/Automation-articles/New-automation-smart-values-in-Jira-Cloud/ba-p/1402775
That is curious, and I suspect you are correct about time zone and the hours/day and days/week setting impacting this. You could try to force to your time zone first and see what happens, such as this using the reporter as the "anchor" time zone. Perhaps log both with and without the increment to see what you get.
{{now.convertToTimeZone(issue.reporter.timeZone)...
Of note, I cannot tell if you are using Cloud or Server/Data Center, and when I checked the current documentation for both, neither one shows that plusBusinessHours() function. But they might be out of date.
What problem are you trying to solve by doing this?
Best regards,
Bill
Thanks for the reply,
I'm on Jira Cloud.
I found the `plusBusinessHours` function mentioned on the blog post I linked to at the bottom of my question.
I experimented a little to force a timezone, but not the way you mention so I will try that approach to see if helps.
If I can't get it working, I suppose I will open a ticket with Atlassian Support.
----
My goal is to calculate a 'follow up' or reminder date time for the ticket. Something like 'add 4 hours' each time a ticket gets a new comment. It would be nice to advance the reminder to the next business day if say the last comment is at 4pm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After a re-read of that article (emphasis is mine below), please note this function targets Jira Service Desk:
You can now play around with timestamp fields by adjusting fields at hour level. For that, you have two new functions in your pocket: plusBusinessHours and minusBusinessHours. We wanted to take business hours window dynamically from Jira Service Desk, but for now, we assume business hours are 9 AM to 6 PM, Monday to Friday.
And with some experimentation... try to log this smart value, from 0 to 10 hours of incrementing:
now+0 hours: {{now.plusBusinessHours(0).fullDateTime}}
and diff of 0 business hour(s): {{now.diff(now.plusBusinessHours(0)).minutes}}
What I see in the log seems to indicate this starts at the next business day's start of hours (9 am) for a 0-hour increment, and continues, wrapping to the subsequent days.
I am unclear of the purpose of this function as it is also not listed on the Jira Service Desk (Management) smart value help.
Definitely time for customer service to chime in on this one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After working with support and a bit of trial and error, I ended up with:
{{now.convertToTimeZone(reporter.timeZone).plusBusinessHours(2)}}
Its too bad you can't pass variables as parameters, I wanted to store the number of business hours (2 in this case) as a variable and pass it to "plusBusinessHours" to simplify the automation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, and I agree. I submitted a defect for not being able to pass variables as function parameters last year. Here are the public backlog items if you want to watch them:
Best regards,
Bill
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.