Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,461,221
Community Members
 
Community Events
176
Community Groups

Using plusBusinessHours does not work as expecte

Edited

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 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Brian Pelton 

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.

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.

audit log.png

I am unclear of the purpose of this function as it is also not listed on the Jira Service Desk (Management) smart value help.

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

 

Definitely time for customer service to chime in on this one.

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. 

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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events