How to Auto-Create Sub-Tasks Linked to Parent Issues in Jira

As a project manager, you want to save time and have better tracking by automatically generating a linked sub-task each time you create a new task. 

Why is this helpful?

  • You can separate an issue into smaller sub-tasks that you can assign to various team members.
  • You can keep track of the time your team spends on the smaller chunks of work supporting an issue.
  • Sub-tasks eliminate guesswork. You can easily report on how an issue is progressing.
  • You can include specific supporting materials to very narrow aspects of an issue. 

GIF of creating a sub-task linked to a parent issue in Jira

Grab this script: 

DC/Server:

string parentIssueKey = key;

string issue_priority  = "Critical";

string issue_summary = "Summary of the sub task";

string issue_description = "Description of the issue";

string issue_estimate = "1h 30m";

date issue_due_date = currentDate() + "30d";

  if ( issueType != "Sub-task") {

  

string k = createIssue("Project Key", parentIssueKey, "Sub-task",issue_summary ,issue_priority, issue_description,"", issue_due_date, issue_estimate, "",{});

  }

CLOUD:

string parentIssueKey = key;

string issue_priority  = "Critical";

string issue_summary = "Summary of the sub task";

string issue_description = "Description of the issue";

date issue_due_date = currentDate() + "30d";

  if ( issueType != "Sub-task") {

  

string k = createIssue("Project Key", parentIssueKey, "Sub-task",issue_summary ,issue_priority, issue_description,"", issue_due_date,"",{});

  }

Step-by-step tutorial 

  1. Open Jira Administration cogwheel and select Projects.
  2. Choose the project that you want to apply the script to, then go to Workflows.
  3. Open your workflow view and click on Edit. 
  4. Click on the Create Issue transition and choose Post Functions from the right-hand side menu.
  5. Click on Add Post Function, choose the SIL Post Function, and click on the Add  button. 
  6. In this case, choose to add a New Script and click on Next. 
  7. Store the script under silprograms folder or any other folder of your choice and give it a name.
  8. Paste the script into the editor and make sure you change the Project Key in line 10 to match your real project’s key.
  9. Click the Save icon in the SIL Manager then click Finish.
  10. Move the post function that you just created to the end of your post functions list. 
  11. Publish your workflow. 

And there you have it. For more details, follow the entire setup in this GIF. 

Make this script your own:

string issue_priority  = “Critical“;

Change this to adjust the priority level, like “Low” or “Medium.” Note, you might have changed the default wording in your unique Jira instance, so check your Priorities window in your Administration dashboard. 

string issue_summary = “Summary of the sub task”;

Here’s where you can change the default name of your subtask. Do you want to include the name of the parent issue in the sub-task name? 

Replace the highlighted portion with something like “New subtask for ” + key;

string issue_description = “Description of the issue”;

You can leave this blank, or add a default description. 

string issue_estimate = “1h 30m”;

Adjust the default completion estimate. You can always individually adjust this later per sub-task. 

date issue_due_date = currentDate() + “30d”;

Add the default due date. You can also change this in the sub-task window. 

Try it out today! 

If you have any questions, reach out to our Support team to request support, report a bug, or suggest a feature.

The Script

DC/Server:

string parentIssueKey = key;

string issue_priority  = "Critical";

string issue_summary = "Summary of the sub task";

string issue_description = "Description of the issue";

string issue_estimate = "1h 30m";

date issue_due_date = currentDate() + "30d";

  if ( issueType != "Sub-task") {

  

string k = createIssue("Project Key", parentIssueKey, "Sub-task",issue_summary ,issue_priority, issue_description,"", issue_due_date, issue_estimate, "",{});

  }

-----------

CLOUD:

string parentIssueKey = key;

string issue_priority  = "Critical";

string issue_summary = "Summary of the sub task";

string issue_description = "Description of the issue";

date issue_due_date = currentDate() + "30d";

  if ( issueType != "Sub-task") {

string k = createIssue("Project Key", parentIssueKey, "Sub-task",issue_summary ,issue_priority, issue_description,"", issue_due_date,"",{});

  }