Get the End Date of the SLA of an Issue

Abstract

This code snippet accesses a specified Service Level Agreement (SLA) of the issue and adds the remaining time to the current date.

Please note: Service Level Agreements are only available in Service Management projects when using Jira Service Management.

Logic

  • Access the threshold data of the ongoing SLA

  • Access the remaining time from the threshold data

  • Add the remaining time to the current date

Snippet

use(groovy.time.TimeCategory){ def remainingTime = issue.get(<SLA>)?.ongoingSLAData?.thresholdData?.get()?.remainingTime?.get() if (remainingTime){ new Date() + (remainingTime / 60000).toInteger().minutes } }

Placeholders

Placeholder Text

Description

Example

Placeholder Text

Description

Example

<SLA>

Name of the Service Level Agreement whose end date should be calculated

'Time to resolution'

Examples

The output of the code snippet above is a Timestamp which you could use in a Groovy expression.

Set a Date/Date-time picker field 

Set the Due date to the end of the “Time to first response” SLA in

  • one of the Set Field Value post-functions

  • the Create issue post-function under Set fields of new issue section

    use(groovy.time.TimeCategory){ def remainingTime = issue.get('Time to resolution'')?.ongoingSLAData?.thresholdData?.get()?.remainingTime?.get() if (remainingTime){ new Date() + (remainingTime / 60000).toInteger().minutes } }

Related articles