Can I create sub-tasks when a specific transition occurs using Automation for JIRA Cloud?

Sam Hall
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.
November 30, 2016

I want to create a set of sub-tasks when a particular transition occurs.

For example, when an issue moves from To Do status to In Progress status, I want to automatically create a couple of sub-tasks.

I only want this to happen once, though - just the first time the issue is transitioned.

I think this is possible with Automation for JIRA (Cloud version), but what is the best way to implement?

Thanks

3 answers

1 accepted

1 vote
Answer accepted
andreas
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.
December 1, 2016

Hi Sam,

I'm one of the creators of Automation for JIRA and you can certainly do this.  Here's what the rule needs to look like:

conditionally-create-subtasks.png

Lets break this down:

  • Whenever an issue is transitioned
  • We use a compare two values condition to check if the status has changed from a particular old value to a new value using this smart-value: 

    {{#changelog.status}}{{fromString}} > {{toString}}{{/changelog.status}}
  • Next we use the "Related issues" condition to check if any sub-tasks are present yet (you could also use JQL here to check for specific sub-tasks)
  • Finally we create 2 new sub-tasks with the "Create sub-tasks" action.

Detecting the status change is a bit complicated still, but we'll ship a new trigger in the next couple of days, that will make this even easier!  It will allow you to run a rule whenever any issue field value changes (including status).

 

andreas
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.
December 3, 2016

Just to let you know - the new trigger I talked about in my answer above is now available in production as well. You can see an example here: https://blog.codebarrel.io/automatically-update-issues-when-a-jira-issue-field-value-changes-d932f3ea6f0f

Makes it a bit easier to trigger a rule when the status changes!

5 votes
Jon Mort [Adaptavist]
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.
December 1, 2016

Hi Sam,

Disclaimer I work on ScriptRunner for JIRA Cloud.

This is exactly the kind of use case ScriptRunner for JIRA Cloud is designed for. You could use a Create Subtask Post Function (http://scriptrunner-docs.connect.adaptavist.com/jiracloud/post-functions.html#_create_subtask) with a condition on the number of subtasks the issue has.

Regards, Jon

Sam Hall
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.
December 1, 2016

Thanks Jon. I'll give it a try and see how it works.

Leo_Poteleanu February 18, 2020

Hi Sam / Jon,

Did you succeede to create a sub-task with this solution?

I did not find the Create Subtask Post Function in Jira Cloud.

Thank you,

Ryan Rules [Adaptavist] February 19, 2020

Hi Leo,

 

When editing your workflow transition, and on the "Post Functions" tab, click "Add post function".

On the next screens which shows you a list of Post Function types, choose "ScriptRunner Post-Function" and click "Add".

On the next screen you can see a list of predesigned post function templates. One of them is:

---

Create Subtask

Creates a configurable subtask

---

You can define a Condition that would allow/disallow the post function to fire, as well as define the field data for the subtask such as the "Summary".

Within the additional section is a code-editor for any more advanced use-cases. From there you can click on any of the examples to paste that code into the editor for your ease of use.

Lastly, you can also read more on how to work with post functions on our documentation page here: https://scriptrunner-docs.connect.adaptavist.com/jiracloud/post-functions.html

This page also goes into more detail regarding the "Create Subtask" post function.

Hopefully this helps!

Many thanks,

 

Ryan

Product Manager - ScriptRunner for Jira Cloud

0 votes
Deleted user December 1, 2016

Sam, There is an add on for multi sub task creation in market place. Once installed, you can see that as part of your post function for your transitions while editing your workflow. Edit the transition for 'To Do', click on Post Functions tab, use the multi sub task utility to define your sub task attributes, publish the updated workflow. Now when you move the issue from To Do status to In Progress, your sub tasks will be automatically be created. You can see them in your issue detail screen. Good luck.

Sam Hall
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.
December 1, 2016

Thanks Guhan. What's the add on called?

Deleted user December 1, 2016

Sam, I used JIRA Suite Utilities (JSU) long time back. I could see that it is not supported by Atlassian anymore, but the functionalities are there in Bobs Issues on Transition related add on too. Market place may have the latest ones and hope you can find one suitable for your environment.

Chirag Ojha May 24, 2019

Is there any way I can achieve a simple feature like assigning sub-task automatically to the main-task assignee, without having to buy a plugin from market place ?

Suggest an answer

Log in or Sign up to answer