Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 3
Next »
This page is about Time to SLA for Jira Server users. |
On this page, you will find Groovy scripts to get detailed info on TTS custom fields. |
If you're using Script Runner Plugin, you can easily use these code snippets to get data. |
Script for Time to SLA custom field
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import java.util.*
import java.text.SimpleDateFormat
import java.sql.Timestamp
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def ttsField = customFieldManager.getCustomFieldObject( "customfield_10600" )
def ttsFieldValue = issue.getCustomFieldValue(ttsField)
def formatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss" )
def result = ""
if (ttsFieldValue && ttsFieldValue. size () > 0 ) {
ttsFieldValue. each {
String slaName = it.slaName
int slaValueAsMinutes = it.slaValue
String slaValueAsTimeString = it.slaValueAsString
String originStatusName = it.originStatusName
String targetStatusName = it.targetStatusName
Date originDate = it.statusDate
Date expectedTargetDate = it.slaTargetDate
Date actualTargetDate = it.untilDate
long timeLeftTillSla = it.timeToSla
String timeLeftTillSlaAsTimeString = it.timeToSlaAsString
boolean isPaused = it.paused
boolean startDateProvidedByDateCustomField = it.startDateProvidedByDateCustomField
boolean endDateProvidedByDateCustomField = it.endDateProvidedByDateCustomField
boolean negotiationDateProvidedByDateCustomField = it.negotiationDateProvidedByDateCustomField
result = "" "
[SLA Name: $slaName]
[SLA Value As Minutes: $slaValueAsMinutes]
[SLA Value As Time String: $slaValueAsTimeString]
[Origin Status: $originStatusName]
[Target Status: $targetStatusName]
[Origin Date: ${formatter.format(originDate)}]
[Expected Target Date: ${expectedTargetDate ? formatter.format(expectedTargetDate) : 'Not yet defined' }]
[Actual Target Date: ${actualTargetDate ? formatter.format(actualTargetDate) : 'Not yet' }]
[Time Left Till SLA as milis: $timeLeftTillSla]
[Time Left Till SLA as Time String: $timeLeftTillSlaAsTimeString]
[Is SLA in Paused Status: $isPaused]
[Is Start Date Provided By Date Custom Field: $startDateProvidedByDateCustomField]
[Is End Date Provided By Date Custom Field: $endDateProvidedByDateCustomField]
[Is Negotiation Date Provided By Date Custom Field: $negotiationDateProvidedByDateCustomField]
<br>
"" "
}
}
result.toString()
|
---|
Sample Result |
---|
[SLA Name: Sla to Resolution]
[SLA Value As Minutes: 240]
[SLA Value As Time String: 4h]
[Origin Status: Open]
[Target Status: Resolved]
[Origin Date: 06 /13/2016 09:33:30]
[Expected Target Date: 06 /13/2016 13:33:30]
[Actual Target Date: Not yet]
[Time Left Till SLA as milis: -34676000]
[Time Left Till SLA as Time String: - 9 hours, 37 minutes, 56 seconds]
[Is SLA in Paused Status: false ]
[Is Start Date Provided By Date Custom Field: false ]
[Is End Date Provided By Date Custom Field: false ]
[Is Negotiation Date Provided By Date Custom Field: false ]
|
Script for SLA Overview Customfield
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import java.util.*
import java.text.SimpleDateFormat
import java.sql.Timestamp
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def overviewField = customFieldManager.getCustomFieldObject( "customfield_10801" )
def overviewFieldValue = issue.getCustomFieldValue(overviewField)
def formatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss" )
def returnString = ""
if (overviewFieldValue && overviewFieldValue. size () > 0 ) {
overviewFieldValue. each {
String slaName = it.slaName def slaStatus = it.status
int slaValueAsMinutes = it.slaValueAsMinutes
String slaValueAsTimeString = it.slaValueAsTimeString
Date originDate = it.originDate
Date expectedTargetDate = it.expectedTargetDate
Date actualTargetDate = it.actualTargetDate
String workingDurationAsTimeString = it.workingDuration
long workingDurationAsSeconds = it.workingDurationAsSeconds
String pausedDurationAsTimeString = it.pausedDuration
String overdueString = it.breachString
int originStatusId = it.sla.originStatusId // next-gen slas doesn't have this field
int targetStatusId = it.sla.targetStatusId // next-gen slas doesn't have this field
boolean negotiationDateProvidedByCustomField = it.negotiationDateProvidedByCustomField
returnString += "" "
[SLA Name: $slaName]
[SLA Status: $slaStatus]
[SLA Value As Minutes: $slaValueAsMinutes]
[SLA Value As Time String: $slaValueAsTimeString]
[Origin Date: ${formatter.format(originDate)}]
[Expected Target Date: ${expectedTargetDate ? formatter.format(expectedTargetDate) : 'Not yet defined' }]
[Actual Target Date: ${actualTargetDate ? formatter.format(actualTargetDate) : 'Not yet' }]
[Working Duration: $workingDurationAsTimeString]
[Working Duration As Seconds: $workingDurationAsSeconds]
[Paused Duration: $pausedDurationAsTimeString]
[Overdue: $overdueString]
[Origin Status Id: $originStatusId]
[Target Status Id: $targetStatusId]
[Is Negotiation Date Provided By Custom Field: $negotiationDateProvidedByCustomField]
<br>
"" "
}
}
returnString.toString()
|
---|
|
|
Sample Result |
---|
[SLA Name: Sla to Resolution]
[SLA Status: EXCEED]
[SLA Value As Minutes: 240]
[SLA Value As Time String: 4h]
[Origin Date: 06 /13/2016 09:33:30]
[Expected Target Date: 06 /13/2016 13:33:30]
[Actual Target Date: Not yet]
[Working Duration: 8 hours, 23 minutes, 16 seconds]
[Working Duration As Seconds: 51796]
[Paused Duration: 0]
[Overdue: 4 hours, 23 minutes, 16 seconds]
[Origin Status Id: 49]
[Target Status Id: 53]
[Is Negotiation Date Provided By Custom Field: false ]
[SLA Name: Trivial Sla]
[SLA Status: STILL]
[SLA Value As Minutes: 1440]
[SLA Value As Time String: 1d]
[Origin Date: 06 /13/2016 09:33:30]
[Expected Target Date: 06 /14/2016 23:54:28]
[Actual Target Date: Not yet]
[Working Duration: 10 minutes]
[Working Duration As Seconds: 600]
[Paused Duration: 1 hour, 13 minutes, 16 seconds]
[Overdue: null]
[Origin Status Id: 49]
[Target Status Id: 54]
[Is Negotiation Date Provided By Custom Field: false ]
|
Script for Overdue Customfield
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import java.util.*
import java.text.SimpleDateFormat
import java.sql.Timestamp
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def overdueField = customFieldManager.getCustomFieldObject( "customfield_10601" )
def overdueFieldValue = issue.getCustomFieldValue(overdueField)
def formatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss" )
def result = ""
if (overdueFieldValue && overdueFieldValue. size () > 0 ) {
overdueFieldValue. each {
String slaName = it.description
int slaValueAsMinutes = it.slaValue
String slaValueAsTimeString = it.slaValueAsString
String originStatusName = it.beforeState
String targetStatusName = it.afterState
Date originDate = it.beforeDate
Date expectedTargetDate = it.expectedTargetDate
Date actualTargetDate = it.afterDate
long workingTimeAsMillis = it.workingTimeAsMillis
String overdue = it.overdue
boolean startDateProvidedByDateCustomField = it.startDateProvidedByDateCustomField
boolean endDateProvidedByDateCustomField = it.endDateProvidedByDateCustomField
boolean negotiationDateProvidedByDateCustomField = it.negotiationDateProvidedByDateCustomField
result = "" "
[SLA Name: $slaName]
[SLA Value As Minutes: $slaValueAsMinutes]
[SLA Value As Time String: $slaValueAsTimeString]
[Origin Status: $originStatusName]
[Target Status: $targetStatusName]
[Origin Date: ${formatter.format(originDate)}]
[Expected Target Date: ${expectedTargetDate ? formatter.format(expectedTargetDate) : 'Not yet defined' }]
[Actual Target Date: ${actualTargetDate ? formatter.format(actualTargetDate) : 'Not yet' }]
[Overdue: ${overdue}]
[Is Start Date Provided By Date Custom Field: $startDateProvidedByDateCustomField]
[Is End Date Provided By Date Custom Field: $endDateProvidedByDateCustomField]
[Is Negotiation Date Provided By Date Custom Field: $negotiationDateProvidedByDateCustomField]
<br>
"" "
}
}
result.toString()
|
---|
Sample Result |
---|
[SLA Name: Sla ro Resolution]
[SLA Value As Minutes: 240]
[SLA Value As Time String: 4h]
[Origin Status: Open]
[Target Status: Resolved]
[Origin Date: 06 /13/2016 12:27:32]
[Expected Target Date: 06 /13/2016 16:27:32]
[Actual Target Date: 06 /13/2016 18:28:49]
[Overdue: 2 hours, 1 minute, 17 seconds]
[Is Start Date Provided By Date Custom Field: false ]
[Is End Date Provided By Date Custom Field: false ]
[Is Negotiation Date Provided By Date Custom Field: false ]
|
Script for SLA Indicator Customfield
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import java.util.*
import java.text.SimpleDateFormat
import java.sql.Timestamp
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def indicatorField = customFieldManager.getCustomFieldObject( "customfield_10700" )
def indicatorFieldValue = issue.getCustomFieldValue(indicatorField)
def formatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss" )
def returnString = ""
if (indicatorFieldValue) {
String result = indicatorFieldValue.result
def overdues = indicatorFieldValue.overdues
if (overdues. size () > 0 ) {
overdues. each {
def overdue = it.value
String slaName = overdue.slaName
int slaValueAsMinutes = overdue.slaValueAsMinutes
String slaValueAsTimeString = overdue.slaValueAsTimeString
Date originDate = overdue.originDate
Date expectedTargetDate = overdue.expectedTargetDate
Date actualTargetDate = overdue.actualTargetDate
String workingDurationAsTimeString = overdue.workingDuration
long workingDurationAsSeconds = overdue.workingDurationAsSeconds
String pausedDurationAsTimeString = overdue.pausedDuration
String overdueString = overdue.breachString
int originStatusId = overdue.sla.originStatusId // next-gen slas don't have this field
int targetStatusId = overdue.sla.targetStatusId // next-gen slas don't have this field
boolean negotiationDateProvidedByCustomField = overdue.negotiationDateProvidedByCustomField
returnString = "" "
[SLA Name: $slaName]
[SLA Value As Minutes: $slaValueAsMinutes]
[SLA Value As Time String: $slaValueAsTimeString]
[Origin Date: ${formatter.format(originDate)}]
[Expected Target Date: ${expectedTargetDate ? formatter.format(expectedTargetDate) : 'Not yet defined' }]
[Actual Target Date: ${actualTargetDate ? formatter.format(actualTargetDate) : 'Not yet' }]
[Working Duration: $workingDurationAsTimeString]
[Working Duration As Seconds: $workingDurationAsSeconds]
[Paused Duration: $pausedDurationAsTimeString]
[Overdue: $overdueString]
[Origin Status Id: $originStatusId]
[Target Status Id: $targetStatusId]
[Is Negotiation Date Provided By Custom Field: $negotiationDateProvidedByCustomField]
<br>
"" "
}
}
}
returnString.toString()
|
---|
Sample Result |
---|
[SLA Name: Sla to Resolution]
[SLA Value As Minutes: 240]
[SLA Value As Time String: 4h]
[Origin Date: 06 /13/2016 09:33:30]
[Expected Target Date: 06 /13/2016 13:33:30]
[Actual Target Date: Not yet]
[Working Duration: 14 hours, 3 minutes, 10 seconds]
[Working Duration As Seconds: 50590]
[Paused Duration: 0]
[Overdue: 10 hours, 3 minutes, 10 seconds]
[Origin Status Id: 49]
[Target Status Id: 53]
[Is Negotiation Date Provided By Custom Field: false ]
|