Restrict the creation of subtasks by the type of the parent ticket
Asked by Manar El Kefi:

Hello, I want to restrict the creation of subtasks by the type of the parent ticket. For example, I don't want a story type parent ticket to have a subtask. How can I do this using automation?


Answers:
author: Hans Polder
body: HI [@Manar El Kefi](/t5/user/viewprofilepage/user-id/5543953) ,

Why would you want to use Automation for this? Could you share a bit more context about the use case/situation you want to solve?

Please keep in mind that natively in Jira this is not supported: <https://jira.atlassian.com/browse/JRACLOUD-7990>


author: Annie _DevSamurai
body: Hi [@Manar El Kefi](/t5/user/viewprofilepage/user-id/5543953)

To restrict the creation of subtasks based on the parent ticket type, you can follow the automation rule below on how to set it up.

1. **Navigate to Automation:**

   * Go to your Jira project.
   * Click on **Project Settings** in the sidebar.
   * Select **Automation** from the settings menu.
2. **Create a New Rule:**

   * Click on **Create Rule**.
   * Choose the **Issue Created** trigger. This sets the rule to activate whenever a new issue, including subtasks, is created.
3. **Add a Condition:**

   * Click on **New condition**.
   * Select **Issue fields condition**.
   * Configure the condition:
     * **Field**: Issue Type
     * **Condition**: equals
     * **Value**: Sub-task (or the specific name of your subtask type)
4. **Branch Rule/Related Issues:**

   * Click on **New branch**.
   * Select **Parent**. This creates a branch that allows you to evaluate the parent issue of the subtask.
5. **Add Another Condition:**

   * Within the parent branch, click on **New condition**.
   * Choose **Issue fields condition**.
   * Set the condition:
     * **Field**: Issue Type
     * **Condition**: equals
     * **Value**: Story (or the specific issue type you want to restrict)
6. **Add an Action:**

   * Click on **New Action**.
   * Choose one of the following actions based on your requirements:
     * **Delete Issue**: This action will delete the subtask if it meets the conditions.
     * **Send Email**: To notify users via email.
     * **Send Slack Message**: To notify users via Slack. You will need to configure the message and provide a Slack webhook URL.
7. **Save and Enable the Rule:**

   * Once you have configured all the components, click on **Save** to save your rule.
   * Ensure the rule is **enabled** by toggling the switch if needed.

Here is the automation flow that I set up based on your requirements above:

* ![Screenshot 2024-08-01 at 17.49.35.png](https://community.atlassian.com/t5/image/serverpage/image-id/339399i882C7BD069A48B40/image-size/large?v=v2&px=999 "Screenshot 2024-08-01 at 17.49.35.png")

I hope this may help!

Annie

comments: author: Annie _DevSamurai
body: To test the rule, you can create a **Story issue** and create **a subtask** under it. Then you can see the subtask is automatically deleted.


author: Manar El Kefi
body: ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/339407i4DA81ECBEF3036EB/image-dimensions/439x311?v=v2 "image.png")


author: Manar El Kefi
body: [@Annie _DevSamurai](/t5/user/viewprofilepage/user-id/5416526) I did the same steps but when I create for example a subtask for a task parent , it's created. I don't know why


author: Annie _DevSamurai
body: [@Manar El Kefi](/t5/user/viewprofilepage/user-id/5543953) have you enabled the rule yet?

You can go to Project settings \> automation \> then Click on the Enable button as the screenshot below

![Screenshot 2024-08-02 at 09.38.05.png](https://community.atlassian.com/t5/image/serverpage/image-id/339593i20F9E1A1798BCEEE/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 09.38.05.png")


author: Manar El Kefi
body: Yes [@Annie _DevSamurai](/t5/user/viewprofilepage/user-id/5416526) , the rule is enabled but it didn't work


author: Annie _DevSamurai
body: [@Manar El Kefi](/t5/user/viewprofilepage/user-id/5543953) There are 2 possible scenarios where it didn't work:

**1. Subtasks Created Before Rule Activation:** If subtasks were created under a parent task before the rule was enabled, enabling the rule afterward will not retroactively apply to these existing subtasks.

<br />

**2. New Subtasks After Rule Activation:** When you enable the rule and create a new Story and then a subtask under it, you may still see the parent task.

However, when you click on the Issue Key, you can't access it anymore,(as the screenshot below) or try reloading the page. You might find that the subtask has already been deleted.

![Screenshot 2024-08-02 at 15.22.15.png](https://community.atlassian.com/t5/image/serverpage/image-id/339645i6AD816F490E1A8E7/image-dimensions/479x226?v=v2 "Screenshot 2024-08-02 at 15.22.15.png")


author: Annie _DevSamurai
body: Also you will get an email notification from Jira that your issue has been deleted like that one:![Screenshot 2024-08-02 at 15.42.46.png](https://community.atlassian.com/t5/image/serverpage/image-id/339646i94ACFF6BD66936EC/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 15.42.46.png")


Tags: cloud

jira-cloud