It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

smart values toBusinessDaysBackwards

dan_finn I'm New Here Aug 13, 2020

I am trying to use smart values to set the date of a custom date picker field to the previous business day based on the issue's due date. 

Using this info I have: {{issue.duedate.toBusinessDayBackwards()}}
This sets the field to the same date as the due date. 

I've also tested out {{issue.duedate.toBusinessDayBackwards(1)}}
This just blanks out the field. 

In the documentation I see that business days are presumed to be M-F 9-6, but do I need to set business days on the project level somewhere?

1 answer

Hi @dan_finn  -- Welcome to the Atlassian Community!

I believe this one is a case-sensitivity issue: dueDate rather than duedate.

And, the "business days" appear to be fixed, as you noted.  The only way I have been able to work around this was quite elaborate:

  • Convert to local time zone.  For example, {{issue.dueDate.convertToTimeZone(reporter.timeZone)}}
  • Parse out everything to separate days and time
  • Recompute differences based upon my company core-working hours.  For example, to accurately compute Age of WIP, I had to...
    • Compute whole days (ignoring the first and last day)
    • Compute first day's delta-hours using your working hours
    • Compute last day's delta-hours using your working hours
    • Sum up

Yup, that is messy  :^)


Best regards,

Bill

dan_finn I'm New Here Aug 13, 2020

Hi @Bill Sheboy

Thanks! Glad to be here & thanks for the thoughtful response as well. 

Unfortunately Im still getting the same behavior with {{issue.dueDate.toBusinessDayBackwards()}} and ...(1)}} but maybe testing on a different set of fields will reveal something.  

Fortunately, we dont have a need to alter our business days, but I imagine that your summary is going to be a huge help for someone out there.    

Regards, 

Dan

Hi Dan,

The Due Date field seems curious, and I got it to work using JSON field editing.  Note this smart value does not match the documentation or what you get back if you query with the REST API.

You can access the value in Due Date for reading with:

{{issue.Due Date}}

To write in the field with Edit Issue, I had to use additional fields with JSON, and the minusBusinessDays function:

{

"fields": {
"myCustomDate": "{{issue.Due Date.minusBusinessDays(1)}}"
}
}

Here is the documentation sources I referenced:

https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/

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

 

Best regards,

Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

3,863 views 22 28
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you