Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Post Function(Create subtask) with a condition

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

0 votes
Answer accepted
Hana Kučerová Community Leader Mar 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.

Hi @Hana Kučerová ! 

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

Thanks! 

Hana Kučerová Community Leader Apr 05, 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

thanks for your answer. We will still trying :)

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you