The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Post Function(Create subtask) with a condition

Alejandra
March 31, 2021

Hello,


I'm configuring a new postfunction with Scriptrunner to create subtasks. I need to check first if the issue has subtasks of the same type. I have added this condition
issue.subTaskObjects.any{ it.issueType.name == "Imputacion de Horas" }
I thought that checked if the issue has subtask of "Imputación de horas", but if the issue has another subtask doesn't generate the subtask. 

Any ideas?

Thank you!! 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Hana Kučerová
Community Champion
March 31, 2021

Hi @Alejandra ,

please, just to be perfectly clear, how this should work...

You want to check, if there's at least one subtask with type "Imputacion de Horas"? No matter which types the other possible subtasks have?

Thank you.

Alejandra
April 3, 2021

Hi @Hana Kučerová ! 

Yes that's correct! i only want to chet that type of subtask! 

Thanks! 

Hana Kučerová
Community Champion
April 5, 2021

Hi @Alejandra ,

this is really weird, I believe your code should work.

I've tested this code using console (with KEY = issue key and NAME = sub-task issue type name):

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue

IssueManager issueManager = ComponentAccessor.getIssueManager()
Issue issue = issueManager.getIssueObject("KEY")
issue.subTaskObjects.any{ it.issueType.name == "NAME" }

If issue with key KEY has at least one sub-task with type NAME, the last row returns true.

Like Alejandra likes this
Alejandra
April 12, 2021

thanks for your answer. We will still trying :)