smart values toBusinessDaysBackwards

Dan Finn August 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

0 votes
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.
August 13, 2020

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 August 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

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.
August 13, 2020

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
AUG Leaders

Atlassian Community Events