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

Apply an SLA based on ticket creation date

Stijn Despiegelaere January 16, 2023

Hi, 

For one client, we have an extended SLA in place with an SLA matrix based on issue priority (3 levels) and the moment an issue was raised (3 possible time windows). 

Our Time to first response and Time to resolution depends on when the ticket was created and what the priority is.

A Critical ticket opened on a Saturday needs an answer within 4 hours. 

A Critical ticket created on a Monday afternoon needs an answer within 2 hours. 

Currently, I haven't been able to automate applying an SLA based on those criteria. 

Does anyone have had any luck with this? 

2 answers

1 accepted

1 vote
Answer accepted
Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 16, 2023

Hi @Stijn Despiegelaere 

Your JQL for the SLA is going to need to incorporate two things:

  • The Priority of a ticket
  • The day it is raised on

---

SLAs

Just to confirm you're aware, one SLA can have multiple Goals - these Goals can use JQL to set different SLA targets depending on the results of the JQL search.

You can add multiple Goals to a SLA using the "+" button just below the original Goal.

For more information on Goals, see this help page

---

JQL for Goals

The JQL for priority should be relatively easy - it should be

priority = Critical

Then, the JQL for the day of the week should be possible using the JQL functions  startOfWeek() and endOfWeek() - these work as follows:

  • startOfWeek() is classed as Sunday, whilst endOfWeek() counts as Saturday
  • You can refer to other days of the week using additional numeric values in the brackets - for example, Monday is startOfWeek(1d)
    • The "d" refers to days. If you're referring to weeks, you don't need a letter
  • This help page explains all the things these functions can do

So for example, we should be able to limit a query to recognise the created day as Saturday by using the following JQL:

priority = Critical AND created >= endOfWeek() AND created < startOfWeek(1)

And Monday's JQL would be:

priority = Critical AND created >= startOfWeek(1d) AND created < startOfWeek(2d)

---

You could use these JQL's in different Goals, with different Time Goals, and they should then set correctly!

Note: The JQL for Saturday is untestedbecause it's not Saturday today. I would strongly recommend testing this before setting it to live in your production environment.

---

Let us know if this helps!

Ste

Stijn Despiegelaere January 16, 2023

Hi, thanks for the help. 

I thought of doing something like this, but was hoping it didn't come to this. Mainly because on top of the day of the week, I need to incorporate the office hours. 

So Monday after 5 PM is treated differently then Monday at 4:30 PM. 

Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 16, 2023

Hi @Stijn Despiegelaere 

Can you explain all the rules in more detail?

Depending on what the rules are and how they're based (eg. per day, or based on the business week, etc) - there might be alternatives using...

  • Different Calendars and/or...
  • Custom Fields and Automation Rules, to provide more metadata to use in the JQL

Ste

Stijn Despiegelaere January 16, 2023

Hi @Ste Wright 

We have three different levels to group our Time to first response: 

  • Office hours: Monday-Friday from 9am to 5 pm
  • Outside office hours on those days
  • Weekends and holidays.

In each of those scenarios, we have a different Time to first response based on the priority of the ticket. There are three levels of priority.

To make matters more complicated, for some priority levels, the time to first response only starts counting on the start of the next business day (so during the times of the Office Hours calendar). 

The priority is given by the external company logging the tickets, but can be changed by us after triage. 

I already tried setting up different calendars (Office Hours, Outside Office Hours, Weekends&Holidays) in one SLA, but during testing, tickets I created during Office Hours showed up with the SLA of Weekends&Holidays since this was ranked higher). 

I had hoped there would be a setting or a way to use those calendars in the JQL to limit that rule to only apply to tickets created during those hours, but had nu luck finding such a setting. 

I could also create three types of requests to add some custom field or use a custom issue type, but then I am expecting the client to choose the right type. The problem with this is that we are based in Belgium, but the client has factories in the US and in Eastern Europe, while the SLA is following our time zone. 

Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2023

Hi @Stijn Despiegelaere 

I think I've found a way to make this simpler. What I did was...

  • Created 2 Custom Fields - Business Week, Business Hours
  • Created 2 Automation Rules to set those Fields
  • Explored having multiple calendars within SLAs

This will provide sufficient parameters to create SLAs (with JQL) based off "working hours" vs "non-working hours".

Note:

  • I would recommend testing this approach thoroughly before going live
  • Your SLAs might still be more complex than what I'm recommending - in that instance I would either...
    • Try to build further on the below or...
    • Question if the SLAs are too complex, and should be reviewed

---

Custom Fields

Create two Select List (single choice) Custom Fields:

  1. Business Week: Yes, No
  2. Business Hours: Yes, No

These will be used in JQL but will be easier to refer to than every day/time of the week using date functions.

Automation will populate them (see below).

---

Automation Rule 1 - Business Week

This rule will populate Business Week as "Yes" if a ticket is created Monday-Friday, or "No" if Saturday-Sunday.

  • Trigger: Issue Created
  • Action: Re-fetch Issue Data
  • Condition: If/Else Block
    • IF...
      • Sub-Condition: Advanced Condition
        • First Value = {{issue.created.convertToTimeZone("<Timezone Here>").format("E")}}
        • Condition = exactly matches regular expression
        • Second Value = (Mon|Tue|Wed|Thu|Fri)
      • Sub-Action: Edit Issue
        • Field = Business Week
          • Value = Yes
    • ELSE-IF...
      • Sub-Condition: Advanced Condition
        • First Value = {{issue.created.convertToTimeZone("<Timezone Here>").format("E")}}
        • Condition = exactly matches regular expression
        • Second Value = (Sat|Sun)
      • Sub-Action: Edit Issue
        • Field = Business Week
          • Value = No

---

Automation Rule 2 - Business Hours

This rule will populate Business Hours as "Yes" if a ticket is created between 9am-5pm, or "No" if not.

  • Trigger: Issue Created
  • Action: Re-fetch Issue Data
  • Condition: If/Else Block
    • IF...
      • Sub-Condition: Advanced Condition
        • First Value = {{issue.created.convertToTimeZone("<Timezone Here>").format("H")}}
        • Condition = exactly matches regular expression
        • Second Value = (9|1[0-7])
      • Sub-Action: Edit Issue
        • Field = Business Hours
          • Value = Yes
    • ELSE-IF...
      • Sub-Condition: Advanced Condition
        • First Value = {{issue.created.convertToTimeZone("<Timezone Here>").format("H")}}
        • Condition = does not match regular expression
        • Second Value = (Sat|Sun)
      • Sub-Action: Edit Issue
        • Field = Business Hours
          • Value = No

---

Automation - Notes

  • These rules are just examples - you'll need to refine them to your company's working days/hours
  • You could take these further - for example, if there's a need to set SLAs based on specific times, you could have further Custom Fields to capture AM vs PM, and further Automation Rules to populate them.
  • The timezone is set on each Advanced Condition to ensure it is consistently set to your timezone. You don't need the "< >" characters - so for example, your timezone might be "Europe/Brussels". See what options exist for timezones on this website (as suggested by Atlassian, on this help page).
  • You can add additional Sub-Conditions for holidays as required - but as these can change year-to-year, I'd recommend using JQL Conditions and searching for specific dates. For example, Christmas might be...
    • created >= 2023-12-25 AND created < 2023-12-26

---

Calendars

You also mentioned that there might be different calendars depending on prioritisation levels.

You can have different Calendars within Jira Service Management - including in the same SLA - to create them:

  • Go to Project Settings > SLAs
  • In the top-right corner, select the Calendar Icon/Button
  • Press the Add Calendar button

You'll need to decide on what parameters you need here, but you can create calendars inclusive of:

  • Working days/hours
  • Holidays (based on date only)

For more information - see this help page

---

Creating the SLAs

You can then put this all together to create your SLAs!

Some will be more complex than others - for example, high priority issues might require a...

  • 24 hour calendar
    • JQL 1 = Within Business Hours
    • JQL 2 = Within Business Week, outside of Business Hours
    • JQL 3 = Weekend

And others might be simpler - for example, low priority issues might require only...

  • Business Hours/Week calendar
  • "All Issues" treated the same

You'll just need to work out each parameter and create an SLA/JQL for it.

 


 

Hopefully this is sufficient to help direct you in the right direction :) - but let us know if you have any further questions or queries!

Just as a final note, I want to say thanks to Bill whose answer in this question helped drive the design above.

Ste

Like Daniel Sidler likes this
Stijn Despiegelaere January 22, 2023

This seems like the way to go. Thanks!

Like Ste Wright likes this
3 votes
Kateryna_v_SaaSJet_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 7, 2023

Hi @Stijn Despiegelaere 

If you don't mind using third-party add-ons, I'll just show you a simpler way to solve this problem using SLA Time and Report for Jira.

In your case, it will be necessary to create 2 SLA configurations, where the first SLA with a Calendar for Saturday and the second one with a Calendar for Monday. If required, you can configure the SLAs for different time zones and work schedules.

Example for Monday SLA:
1) Select the Monday calendar and set up the START/PAUSE/STOP conditions.
1.png
2) Choose the required SLA Time goals, and the Limit exceeded actions.
2.png
Use the Notification template editor for your custom message.
3.png
3) Save. Do the same for Saturday.

You can use the 30-day add-on trial to check how it suits you.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events