Hi Team,
I want to calculate Actual time spent by User in JSD for this i need script pls share to me if any body have.
Goal time = 1h
Actual time spent=24mintues i want to update this time on my ticket view screen.
remaining time =36min
How are you defining time spent? How are they entering a differing value into Jira?
based on SLA if you gine thoruth SLA You can see actual time spent by user out of SLA goal time
I know an SLA measure a length of time between updates and an agent will not start as soon as it arrives and finish when it ends (e.g. an issue that takes an hour to fix, but you've been doing more urgent stuff for six hours).
But how are you telling Jira the actual time spent? Where is the agent recording that they spent an hour on something?
In this case different classes in the SLAValue.class have to been checked CompletedSLAData and OngoingSLAData The result is only showed when the status are Solved, Resolved, Done or Closed (depending on the type of issue)In my SLA clock configuration when Solved, Resolved or Done the clock is paused, and when Closed the clock is stopped.
//////this is my code but am showing errors can u help me out this
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.CustomFieldManagerimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.ComponentManager
// ------- FUNCTIONS
// Get minutes per type of issue and priority/urgencylong goalMinutesPerPriorityOrUrgency(type, value) {def valueCopied = valueswitch (type) {case "Incident":result = goalMinutesPerIncidentPriority(valueCopied)breakcase "Request for Change":result = goalMinutesPerRfCPriority(valueCopied)breakcase "Task":result = goalMinutesPerTaskUrgency(valueCopied)breakdefault:result = 0}result}
// Minutes per incident by prioritylong goalMinutesPerIncidentPriority(priority) {switch (priority) {case "Blocker":result = 240 //4hbreak// more cases ...
default:result = 0}result}
// Minutes per RfC by prioritylong goalMinutesPerRfCPriority(priority) {switch (priority) {case "Blocker":result = 240 //4hbreak// more cases ...default:result = 0}result}
// Minutes per task by urgencylong goalMinutesPerTaskUrgency(urgency) {switch (urgency) {case "Critical":result = 480 //8hbreak// more cases...default:result = 0}result}
// ------- MAIN// Return every value in minutes
// Status of the issue is saveddef statusName = issue.getStatusObject().getSimpleStatus().getName();
if ((statusName == 'Solved') || (statusName == 'Resolved') || (statusName == 'Done') || (statusName == 'Closed')){CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()def componentManager = ComponentManager.getInstance()def changeHistoryManager = componentManager.getChangeHistoryManager()// Time to Resolution custom field from SLA calculations (Service desk plugin)CustomField cf_timeToResolution = customFieldManager.getCustomFieldObject((long))(10035) //Put your Time to Resolution custom field IDdef timeToResolution = issue.getCustomFieldValue(cf_timeToResolution)long result = 0def issueTypeName = issue.getIssueTypeObject().getName() // Incident, Request for Change, Taskdef priorityOrUrgency = ""// I use urgency for tasks instead of Priorityif (issueTypeName == "Incident"){// Get Urgency field from issue of type TaskCustomField cf_urgency = customFieldManager.getCustomFieldObject(10025) // I use Urgency for task instead of PrioritypriorityOrUrgency = issue.getCustomFieldValue(cf_urgency)}else{// Get Priority value from issue of type Incident or Request for ChangepriorityOrUrgency = issue.getPriority().getString("name")}/*CompleteSLAData is only filled when the issue has the SLA clock stopped (passed through 'Solved' or 'Resolved' to 'Closed')OngoingSLAData is only filled when the issue has the SLA clock running or paused.*/if (timeToResolution != null){// SLA clock stopped - get from CompleteSLADataif (timeToResolution.getCompleteSLAData().size() > 0){// Get elapsed time from Service Desk plugin libraries after have decompiled the .jarlong timeToResolutionMillis = timeToResolution.getCompleteSLAData().get(0).getElapsedTime()// Convert time to minutesdouble timeToResolutionMinutes = timeToResolutionMillis / (1000*60)return timeToResolutionMinutes.round().toString();}// SLA clock paused - get from OngoingSLADataelse{double elapsedTime = 0;if (timeToResolution.getOngoingSLAData() != null){// Get StarTime from OngoingSLADatadouble remainingTimeMin = (timeToResolution.getOngoingSLAData().getThresholdData().get().getRemainingTime().get()) / (1000*60)long remainingTimeMinLong = remainingTimeMin.round().longValue()if (remainingTimeMin < 0) // RemainingTime is negative{elapsedTime = elapsedTime.sum(goalMinutesPerPriorityOrUrgency(issueTypeName, priorityOrUrgency), remainingTimeMinLong.abs())}else{elapsedTime = goalMinutesPerPriorityOrUrgency(issueTypeName, priorityOrUrgency).doubleValue() - remainingTimeMin}}return elapsedTime.round().toString()}}
It looks like you're new here. Sign in or register to get started.