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

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

prevent subtask creation/issue creation.


Hi Team,

i need help for few of my questions and if its possible then how to implement them .

In JIRA workflow for my client ,i have created grrovy script that creates subtask when parent issue is created but now i wanted to add some constraints when a manual subtask is being created for a parent issue.

1. if autocreated subtask exists with same summary then manually new subtask  should not be created.

2. if my parent issue is makred to done then also it should not allow to create a new subtask manually.

3. parent issue is marked to done, once all subtasks are done then subtasks should not be allowd to move into other status even if transition from done to inprogress does exist.


Kinldy provide some code or scripts that can help me achiving above mentioned points.


Thanks in advance !

1 answer

1 accepted

Hey there, I think I have a viable solution for each of your requests. So I'll go through each one-by-one:

1. For your first requirment, it would be easiest to hide the Create-Subtask UI element using one of the built in Script Fragments. You can find these by pressing the "." (period) key while in your JIRA instance and searching for "Script Fragments." The fragment that you want to add is "Hide system or plugin UI element." Once you are in the creation screen for that fragment, add this code to the "Condition" block:


def currentStatus =

!(currentStatus == "Done")

And select the create-subtask element from the web-items to hide. The code states that if an issue is in the "Done" status, then the Create-Subtask option will not appear on the issue view screen. Additionally, if you would like to do more than just remove the option from view, you can add a script validator to the Create transition, similar to the route I take below.

2. For your second requirment, you need to make a simple script validator on the Create transition in your workflow (if you need assistance in setting that up, let me know). The condition you use should look something like this:

    def issueParent = issue.getParentObject()
    def parentSubTasks = issueParent.getSubTaskObjects()
    def currentSubTaskSummary = issue.getSummary()
    !parentSubTasks.find{it.getSummary() == currentSubTaskSummary}

This condition checks every other subtask assigned to its parent issue and ensures that the subtask being created is not a duplicate. Add an appropriate error message and leave the Field box blank (make sure you publish the workflow after adding the validator).

3. For your third requirment, you need to add another workflow validator to every transition that is not your "Done" transition. I wasen't quite sure what you were asking for in the third point, so this is what I came up with:

    if(issue.getParentObject() == "Done")
        ! == "Done"

This condition essentially makes it so that a subtask cannot transition to the status associated with this validator if its parent's status is set to "Done." Again, add the appropriate error message and leave the Field box blank. Just to reiterate, this validator must be added to every transition that is not your "Done" transition to ensure that a subtask cannot be set to any of those statuses.

That's all I've got! Let me know if you need help or further clarification with any of this!





Hi Aiden - i have similar need for the first one but instead of stopping manual sub-task from being created, i want to stop a duplicate from being created on the transition (if the workflow went back a step and then forward again).

any ideas on this one? 



Hey Tracey!

Assuming you are using the Create Subtask SR post-function, you should be able to use a condition like this to check if the issue already has a subtask with the given summary:

import com.atlassian.jira.component.ComponentAccessor

def subtasks = issue.subTaskObjects
if(subtasks.find{it.summary == "Subtask Summary"})
return false
return true

Hi Aidan,

I have the exact requirement to prevent sub-task creation(1 issue in the above question)  so can you please guide me where do i need to add this code in script runner as i am new to jira cloud.




Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence Cloud

🎨 Add some visual life to your templates

Hi Atlassian Community, My name is Avni Barman, and I am a Product Manager on the Confluence Cloud team. Based on feedback from you, we are giving admins more power to create templates that a...

131 views 1 5
Read article

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