Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

SLA custom field

Tsuyoshi Shimabukuro
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 23, 2018

Hello Community,

I have a requirement to calculate the cost of a breached SLA. I thought I can use the remaining time of SLA custom field and a ScriptRunner Script Field.

My question is about the value of the remainingTime using the bellow script in Script Console:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue;

// Key of a Service Desk Issue
Issue subIssue = ComponentAccessor.getIssueManager().getIssueObject("KEY")

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def timeToSlaField = customFieldManager.getCustomFieldObjectByName("NAME OF SLA FIELD");
def value = timeToSlaField.getValue(subIssue)

// remaining time in milliseconds
def remainingTime = value.ongoingSLAData.thresholdData.get().remainingTime.get()

The script returns a value in milliseconds that is different from the one displayed in the GUI  (issue view, queues...) and I can not figure out how to understand it.

At the beginning when the issue is created it seems that the remainingTime is set to the value of the SLA goal then the value changes but not every millisecond (?)

For example on the image below an issue on which 19 min remains until SLA breach.

 time to first answer vs. remainingTime in milliseconds from the script

image.png

  1. Am I working on the wrong Field/attribute... ?
  2. What am I missing on the remainingTime ? Should it be interpreted in regard of another field such as a changeDate or calculatedDate available in the SLAValue ?
  3. Should I change my mind and try a different approach ?

Any help would be greatly appreciated :) 

Thanks

3 answers

0 votes
Pavel Abdi March 16, 2020

Hi everyone!

Since I'm using Jira Service Desk, I found a solution for this case by using Jira Service Desk REST API https://docs.atlassian.com/jira-servicedesk/REST/3.6.2/

Ming P
Contributor
March 16, 2020

oh haha!I got this before u reply me

0 votes
Ming P
Contributor
March 15, 2020

I have the same question for this,so is there any resolution now?

0 votes
Pavel Abdi December 9, 2019

Hi everyone!

I've faced the same problem. For instance, I need to get issues in which approvals are 10 hours overdue. I can find them with the following JQL: 'cf[12000] <= remaining("-10h")', where cf[12000] is an SLA CustomField Type custom field.

However, I can't get the remaining time from the custom field via a script the way @Tsuyoshi Shimabukuro has described. The remainingTime value doesn't seem to change in issues with ongoing SLA. At least, it doesn't change in the real time. Is there any update time interval for this value or do I get the remainingTime wrong?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events