Hi Team,
I have a requirement to count the no.of "Connection" subtasks and display them on the custom field. We have two subtask, one is a "Sub-task" and another is "Connection". The main parent ticket will have both Sub-task and Connection subtasks, but want to display the only "Connection" tickets, the following scripts is displaying all subtasks. is there any correction to update the only "Connection" subtasks in that custom field "Connection Count" ?
Scripted Field : Connection Count
def subTaskSum = 0
issue.getSubTaskObjects()?.each {
subtask -> subtask.getResolution()==null?subTaskSum += 1:subTaskSum
}
return subTaskSum
Hi @Lakshmi CH ,
Do I understand that you want to have a counter on an issue that counts all:
- subtasks, but only of specific type "Connection"
- No further conditions?
I ask this because in your script you have put a condition on the resolution of the subtasks, which does not reflect in your requirements.
You were already going in the correct direction with your code, I just altered it a bit to reflect issuetype instead of resolution.
def numberofConnectionSubtasks = issue.getSubTaskObjects().findAll() { a ->
a.getIssueType().name == "Connection"
}.size()
return numberofConnectionSubtasks ? numberofConnectionSubtasks as Integer : null
instead of the name, you could better use the id of the issuetype, as this is more stable. ;)
Hope this helps,
Tessa
Thank you so much @Tessa Tuteleers for your quick response. Its working as expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.