I want my SLA to show how many SLAs are concluded until the item is resolved

Cloud Migration Resources

Planning a Cloud migration? These resources can help you get started:

Time to SLA Cloud features – Review Cloud features and understand key differences between DC and Cloud.
Migration support from Appfire – Learn how we can help you migrate smoothly.

I want my SLA to show how many SLAs are concluded until the item is resolved

Context: A user wants to track the time between an external comment and a public comment made by one of their agents.

User problem: As a Project Manager, I want to track the time between an external comment and a public comment made by one of our agents. But I’d also appreciate a perspective on the % of responses made within two days.

Solution: Using the workflow and post conditionswe’ve given below.

To examine this use case, let’s assume the user’s workflow is as follows:

Solution

  1. Configure an SLA (named Response SLA, in this example) with the following parameters:

    • SLA Start: Waiting for Support

    • SLA End: Waiting for Customer

    • SLA Goal: 2d

    • Calendar: Choose any calendar that fits your use case

    • Calculation Method: Last Cycle

Please limit this SLA to the workflow that is shown above, like this:

  1. Set the SLA Reset condition in the Waiting for Support transition. This allows the SLA to restart when an issue transitions to Waiting for Support status.

You can set up Automation Rules for this workflow to automatically transition to the Waiting for Support status when a customer enters a comment. Similarly, you can set up an automation rule for this project to allow work items to transition to the Waiting for Customer status when agents make a public comment.

  1. Create three custom fields (single-line text field) named Exceed Count, Met Count, and Total Count. Add these fields to the project's view work item screen with a default value of 0. Click on the cog icon > Edit and take a look at the URL of the page, and note the custom field id present in the URL. 

  2. Place the following script in the first place in the Waiting for Customer transition.

This guide assumes that only the Response SLA is active in this workflow. If there are more SLAs, you need to modify the below script accordingly.

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.util.DefaultIssueChangeHolder def customFieldManager = ComponentAccessor.getCustomFieldManager() def issueManager = ComponentAccessor.getIssueManager() //find your met count, exceed count and total count id's and put it here instead of 12000,12001, and 12002 def metField= customFieldManager.getCustomFieldObject(12001) def exceedField= customFieldManager.getCustomFieldObject(12000) def totalField= customFieldManager.getCustomFieldObject(12002) String metFieldValue_string= issue.getCustomFieldValue(metField) String exceedFieldValue_string= issue.getCustomFieldValue(exceedField) String totalFieldValue_string= issue.getCustomFieldValue(totalField) Integer metFieldValue= metFieldValue_string.toInteger() Integer exceedFieldValue= exceedFieldValue_string.toInteger() Integer totalFieldValue= totalFieldValue_string.toInteger() def changeHolder= new DefaultIssueChangeHolder() // find your SLA Overview field's ID and put it here instead of 10303 def overviewField = customFieldManager.getCustomFieldObject(10303) def overviewFieldValue = issue.getCustomFieldValue(overviewField) def slaStatus="" // SLA Overview field returns a list and we'll get the SLA indicator information if (overviewFieldValue) { overviewFieldValue.each { slaStatus = it.status } } if (slaStatus.toString().equals("EXCEED")){ exceedFieldValue=exceedFieldValue+1 exceedField.updateValue(null,issue,new ModifiedValue(issue.getCustomFieldValue(exceedField),Integer.toString(exceedFieldValue)),changeHolder) totalFieldValue=exceedFieldValue+metFieldValue } else if (slaStatus.toString().equals("STILL") || slaStatus.toString().equals("SUCCESS")){ metFieldValue=metFieldValue+1 metField.updateValue(null,issue,new ModifiedValue(issue.getCustomFieldValue(metField),Integer.toString(metFieldValue)),changeHolder) totalFieldValue=exceedFieldValue+metFieldValue } totalField.updateValue(null,issue,new ModifiedValue(issue.getCustomFieldValue(totalField),Integer.toString(totalFieldValue)),changeHolder)

5. Save the script, and you're done!

Need support? Create a request with our support team.

Copyright © 2005 - 2025 Appfire | All rights reserved.