Copy SLA information to a Custom Field


This script helps you to copy a SLA field to another custom field.


As a project manager, I want to export SLA field to an Excel file. The default SLA field does not export correctly, so a custom field with a copy of the SLA information can be created for later export.

Good to Know

  • Use Text Field (multi-line) as template for the custom field.


import com.atlassian.jira.component.ComponentAccessor import import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin @WithPlugin("com.atlassian.servicedesk") @PluginModule SlaInformationService slaInformationService // SLA field name final slaName = '' // Gets the SLA information querying SLA service for the current issue def query = slaInformationService.newInfoQueryBuilder() .issue( .build() def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser def slaFormatter = slaInformationService.durationFormatter def sla = slaInformationService.getInfo(user, query).results.find { == slaName } if (sla?.ongoingCycle?.isPresent()) { // If there is an ongoing SLA. it takes the current ongoing SLA remaining time and format it as duration of "X hours Y minutes" slaFormatter.format(user, sla.ongoingCycle.get().remainingTime) } else { // If there is no ongoing SLA, it takes last completed cycle remaining type and format it as duration of "X hours Y minutes" slaFormatter.format(user, sla.completedCycles.last().remainingTime) }
Discovered an issue? Report it here

Suggested for you