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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,972
Community Members
 
Community Events
184
Community Groups

Blocking of Auto sub-task creation if subtask in parent with same summary already exists?

I have set up auto-sub task creation using post functions on a couple of transitions in our workflow. However, I our workflow can go back and forth between stages, and therefore i only want the sub-tasks to create the first time it gets transitioned.

Is there a script that i can use in the condition section of the post-script auto-sub task function that will only create the sub-task if a sub-task with the same summary doesn’t already exist on the Parent?  If it does exist, then the sub task wont’ create, but if sub-task doesn’t already exist, then it will create.

 thanks

Tracey

2 answers

Hello i know this is old post but i am facing same issue, 

 sub task wont’ create, but if sub-task doesn’t already exist, then it will create.

 Can you please help me with this script

Thanks,

Siva.

Hi

I"ve added the below script into the create a sub-task post function code editor condition. You'd need to update 'manage onboarding' to be the relevant summary of the sub task that you don't want to re-create if the same summary exists. 

import com.atlassian.jira.component.ComponentAccessor

 

def subtasks = issue.subTaskObjects

if(subtasks.find{it.summary == "Manage Onboarding"})

{

    return false

}

else

{

    return true

}

Like siva likes this

Hi @Tracey Ryan thanks for the responce,

It work's for me.

Thanks,

Siva

0 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 18, 2017

You will need to add a condition on your subtask creation workflow postfunction.

The condition may look like below

(PLEASE NOTE : THIS IS NOT  A WORKING SCRIPT JUST FOR YOUR REFERENCE , I have not tested this , it may or may not work . Please try on your test instance)

for( def subtask in issue.subTaskObjects){
if(subtask.summary == "your summary")
return false
}

thanks Mizan - yeah i know i need a condition but not sure how to write the script. I tried your example above but it didn't work. It blocks the sub-task from creating at all on the transition, even if one doesn't exist already.  hopefully someone has been able to do this successfully and can provide the exact script. 

 

thanks for your help. 

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 19, 2017

All the best :)

Hello @Tracey Ryan  i know this is old post but i am facing same issue, 

 sub task wont’ create, but if sub-task doesn’t already exist, then it will create.

 Can you please help me with this if you got any script to resolve this

Thanks,

Siva.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events