Our new Appfire Documentation Space is now live! Take a look here!

If you have any questions please email support@appfire.com

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Tip

See our new groovy scripts document.

In this section, you can find Groovy scripts to get detailed info of TTS custom fields.

...

Script for SLA Overview Customfield

...



Code Block
languagegroovy
linenumberstrue
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
 
// get CustomFieldManager instance
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// find your SLA Overview field's ID and put it here instead of 10801
def overviewField = customFieldManager.getCustomFieldObject("customfield_10801")
def overviewFieldValue = issue.getCustomFieldValue(overviewField)
// date/time formatter will be used to format date attributes
def formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
def returnString = ""
// SLA Overview field returns list
if (overviewFieldValue && overviewFieldValue.size() > 0) {
    // if there is overdue, then all details of overdues are in 'overdues' attribute
        overviewFieldValue.each {
            String slaName = it.sla.description
			def slaStatus = it.status
			int slaValueAsMinutes = it.sla.slaValue
            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
            // if there is overdue
            String overdueString = it.breachString
            int originStatusId = it.sla.originStatusId
            int targetStatusId = it.sla.targetStatusId
            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()

...

Code Block
languagebash
[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

...

Code Block
languagebash
titleSample 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

 


Code Block
languagegroovy
linenumberstrue
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()
// find your SLA Indicator field's ID and put it here instead of 10700
def indicatorField = customFieldManager.getCustomFieldObject("customfield_10700")
def indicatorFieldValue = issue.getCustomFieldValue(indicatorField)
def formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
def returnString = ""
// SLA Indicator field returns an object
if (indicatorFieldValue) {
    String result = indicatorFieldValue.result
 
    // if there is overdue, then all details of overdues are in 'overdues' attribute
    def overdues = indicatorFieldValue.overdues
    if (overdues.size() > 0) {
        overdues.each {
            def overdue = it.value
            String slaName = overdue.sla.description
            int slaValueAsMinutes = overdue.sla.slaValue
            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
            int targetStatusId = overdue.sla.targetStatusId
            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()

 

 



Code Block
languagebash
titleSample 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]