Forums

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

Block subtask creation when the parent issue is done for specific issue type

Ryan Bullock September 7, 2023

We have a workflow with the issue types Epic, Task, and Sub-task. We also have a separate workflow with the issue type Request. The script is blocking the Sub-task creation as expected, but is also blocking the ability to create Epic and Tasks that follow the same workflow. Ideally we would like Sub-tasks to be blocked if the Request issue type is Closed/Done, but it is fine if it applies to all. Any ideas?

Have tried multiple variations of the solutions offered here but none have worked:

https://community.atlassian.com/t5/Jira-Software-questions/How-to-block-subtask-creation-when-the-parent-issue-is-done-for/qaq-p/2094445#U2471377

 

 

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2023 edited

Hi @Ryan Bullock

For your requirement, I suggest using ScriptRunner's Custom Script Validator instead of the Simple Script Validator.

Below is a sample working code for your reference:-

import com.opensymphony.workflow.InvalidInputException

if (issue.isSubTask() && issue.parentObject.status.name == 'Done') {
throw new InvalidInputException('sub-tasks', 'Sub-Taks cannot be created if the issue is Done')
}

Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below are the screenshots for the validator configuration:-

 1. Select the Create transition. Once the dialog appears, click on the Validators link as shown in the screenshot below:-validator_config1.png

2. Once on the validators Post-Function configuration page, click add validator as shown in the screenshot below:-validator_config2.png

3. Select Custom script validator [ScriptRunner] as shown in the screenshot below

validator_config3.png

4. Finally, add the sample script I provided into the Inline editor and publish the changes.

validator_config4.png

Below are a couple of test screenshots for your reference:-

1. To test the validator, I am going to try and create a Sub-task on a Story that is part of an Epic which is in Done status as shown in the screenshot below:-

test1.png

 

2. I enter some values into the Sub-task fields and click on the create button as shown in the screenshot below:-

test2.png

3. As expected, the error message does not permit me to create Sub-tasks for Done Issues.

test3.png

4. Next, I try to create a new Story and enter some details as shown in the screenshot below:-

test4.png

5. As expected, the new Story is created without any issues.

test5.png

 

I hope this helps to solve your question. :-)

Thank you and Kind regards,

Ram

 

Ryan Bullock September 11, 2023

Hi Ram, thank you for the detailed solution! It is working as expected as it no longer blocks the Epic and Tasks.

Is there a way to apply this so that it only applies to a specific parent issue type? For example, if we wanted to have it only apply to subtasks created under a 'Done' Task issue type, but not apply if it is a Subtask under an Epic? 

Cheers,

Ryan

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2023

Hi @Ryan Bullock 

If you intend to make the validator specific for only the Task issue type, all you have to do is modify the if condition from this:-

import com.opensymphony.workflow.InvalidInputException

if (issue.isSubTask() && issue.parentObject.status.name == 'Done') {
throw new InvalidInputException('sub-tasks', 'Sub-Taks cannot be created if the issue is Done')
}

to this:-

import com.opensymphony.workflow.InvalidInputException

if (issue.isSubTask() && issue.parentObject.status.name == 'Done' && issue.parentObject.issueType.name == 'Task') {
throw new InvalidInputException('sub-tasks', 'Sub-Taks cannot be created if the issue is Done')
}

I hope this helps to solve your question. :-)

Thank you and Kind regards,

Ram

Like Ryan Bullock likes this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events