We use ScriptRunner to create Sub-tasks. All the fields from the Parent task are copied over to the Sub-Task. All the Sub-tasks are handled by another team and display the SLAs of parent ticket is causing confusion. Is it possible to clear the SLA on the sub-task when it gets created using Additional Issue Actions?
Community moderators have prevented the ability to post new answers.
Hi Yashir,
It is not possible to clear the issue actions using Service Desk for the SLA Fields due to the fact the SLA fields store multiple values in them.
If you run the code below in the Script Console then you will see what an SLA value looks like.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue; // Enter the Key of a Service Desk Issue here. Issue subIssue = ComponentAccessor.getIssueManager().getIssueObject("KDSD-39") def customFieldManager = ComponentAccessor.getCustomFieldManager() def timeToSlaField = customFieldManager.getCustomFieldObjectByName("Time to first response"); // Show the value held for that field in the database. return timeToSlaField.getValue(subIssue).toString()
One workaround would be to create a custom script post function below the Script Condition that create the sub task on the transition and add code in similar to below to remove the SLA field on the subtask. Note - This example code will need refactoring so you don't clear the SLA value on the parent task as it currently clears the value on the parent task as well.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue // Get the required Managers def customFieldManager = ComponentAccessor.getCustomFieldManager() // Get the SLA Custom Fields def timeToResolution = customFieldManager.getCustomFieldObjectByName("Time to resolution"); def timeToFirstResponse = customFieldManager.getCustomFieldObjectByName("Time to first response"); // Construct the key of the next Subtask def currentIssue = issue.toString() // Extract the project key from the issue def projectKey = currentIssue.replaceAll("[^A-Z]","").toString(); // Get the Issue Number as an integer def CurrentIssueNumber = currentIssue.replaceAll("[^1-9]","").toInteger(); // Increment th issue number by 1 def SubTaskIssueNumber = CurrentIssueNumber + 1 // Constrcut the Issue Key of the next SubTask def subTaskKey = projectKey + "-" + SubTaskIssueNumber // Construct a pointer to the subtask issue object MutableIssue subIssue = ComponentAccessor.getIssueManager().getIssueObject(subTaskKey) if (subIssue) { // Clear the SLA Fields timeToResolution.remove() timeToFirstResponse.remove() }
I hope this helps.
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.