SLAValue class (Scriptrunner)

NeriyaG June 19, 2016

Hi, I can't find the SLAValue class in the API.
I'm trying to create a scripted field which shows the SLA goal (as date&time, instead of hours remaining)
This is where i get stuck:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue;
def issue = ComponentAccessor.getIssueManager().getIssueObject("SSD-24279")
def cfm = ComponentAccessor.getCustomFieldManager();
def sla = cfm.getCustomFieldObjectByName("Time to resolution");
def time = issue.getCustomFieldValue(sla)
return time

i get an SLAvalue object which contains this data:
SLAValue{completeSLAData=[], timeline=Timeline{events=[TimelineEvent{date=2016-06-16T12:55:17.511Z, types=[START]}]}, ongoingSLAData=OngoingSLAData{goalId=28, startTime=2016-06-16T12:55:17.511Z, paused=false, thresholdData=some(ThresholdData{calculatedAt=2016-06-16T12:55:17.511Z, remainingTime=some(97200000), thresholdsConfigChangeDate=2016-05-09T12:26:51.000Z, thresholdsConfigChangeMsEpoch=1462796811489})}, metricId=5, definitionChangeDate=2016-06-15T08:09:13.000Z, definitionChangeMsEpoch=1465978152872, goalsChangeDate=2016-05-16T06:15:02.000Z, goalsChangeMsEpoch=1463379302317, goalTimeUpdatedDate=2016-05-16T06:15:02.000Z, goalTimeUpdatedMsEpoch=1463379302294, metricCreatedDate=1462796811489}

I can't import this class com.atlassian.servicedesk.internal.sla.model.SLAValue
What should I do?
Thanks!

 

2 answers

0 votes
Edvinas September 24, 2020

Hello,

If you cant import class you could try some reflection. In java it should look like this.

final Class<?> aClass = slaValue.getClass();
Method getGoalsChangeDateMethod = aClass.getMethod("getGoalsChangeDate");
Object result = getGoalsChangeDateMethod.invoke(slaValue);
result.toString();

My debug console:
Screen Shot 2020-09-24 at 10.34.20.png

 

0 votes
Patrick van der Rijst
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 6, 2016

Hey,

 

Have you been able to resolve this?

Suggest an answer

Log in or Sign up to answer