How to use smart values to set a 3 day working automated SLA on a ticket?
Asked by David Naylor:

I'm trying to set up a ticket SLA based on 3 working days so:

- if it's opened on a Friday after 5.30pm, Saturday or Sunday the clock 'starts' at 9am on Monday.

- if it's opened after midnight but before 9am, the clock starts at 9am the same day

- if it's opened after 5.30pm, the clock starts at 9am the next working day.

I've worked out the logic for each if/else block in order to calculate the 'startTimer' value in each scenario and have been using Log Action to print the relevant values to the log so I can confirm each works correctly. The routine is failing each time I try to set the endTimer - 3 business days after the startTimer value. An example is below using values from the log.

Issue created: 2024-05-30T18:24:47.4+0000

As this is after hours, the startTimer value is calculated as:

startTimer = {issue.created.plusDays(1).withHour(9).withMinute(0)}}

and the correctly logged value is:

startTimer = 2024-05-31T09:00:47.4+0000

Use plusBusinessDays to set the end timer and it fails to return a value

endTimer = {{startTimer.plusBusinessDays(3)}}

endTimer **returns as null**

The automation shows that it has been executed successfully. What am I missing in the way I use the smart value? thanks


Answers:
author: Mikael Sandberg
body: Hi [@David Naylor](/t5/user/viewprofilepage/user-id/5498413)

Welcome to Atlassian Community!

You do not have to use automation to do this, all you have to do is go and change the calendar used by the SLA so that the calendar is not counting the weekend. Here is an example of the 9-5 workday calendar

![Screenshot 2024-07-10 at 1.12.34?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/334786iB014B924D48191CB/image-dimensions/304x288?v=v2 "Screenshot 2024-07-10 at 1.12.34?PM.png")

If a request is created outside of the defined times the SLA will be paused until the next work day.

comments: author: David Naylor
body: Hi [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579)

Thanks. I'm using a Jira software project and the only settings I can find to control hours are the Time Tracking settings (below). I think your screenshot is from a service project? If not, can you point me to that setting?   

![Screenshot 2024-07-10 at 22.07.56.png](https://community.atlassian.com/t5/image/serverpage/image-id/334794iD965C666B8BD088B/image-size/large?v=v2&px=999 "Screenshot 2024-07-10 at 22.07.56.png")


author: Mikael Sandberg
body: Okay, your question ended up in the wrong collection then.

The time stamps that you are trying to set are related to time tracking, not SLAs. So are you trying to use time tracking as some sort of SLA? The error you get on the end time is expected since the log work does not allow you to set a future date in it.

In order to use SLAs in Jira Software you would have to either use your own custom fields for the start/end dates or use one if the [SLA apps](https://marketplace.atlassian.com/search?hosting=cloud&product=jira&query=SLA) in the Marketplace.


author: David Naylor
body: Thanks Mike. Yes I'm using all custom fields. Ultimately the endTimer value is written to a custom field called Due time-date which we monitor in our reporting. I sorry but I don't follow your point about 'the log work does not allow you to set future date in it'.

If the startTimer value is constructed correctly, why does the plusBusinessDays smart value not work?

The last element of my if/else structure doesn't need me to set the value of endTimer since I don't need to account for out of hours. In this step I simply use:

Due time-date = {{issue.created.PlusBusinessDays(3)}}

and that works fine


author: Mikael Sandberg
body: Okay, because you included the screenshot of the time tracking feature I assumed you tried to use those date fields.

So are startTimer and endTimer both variables? The reason that {{startTimer.plusBusinessDays(3)}} is not working could be that you need to convert it to a date format that Jira understands. You could try and add .jiraDate at the end to see if that returns a value.


Tags: automation

cloud

jira-service-management

jira-service-management-cloud

smart-value