Auto populate sub-tasks of a ticket with a template
Asked by Daniel Hammerin:

Long story short, I have set up 1 custom field for all of our issue types that is presented on the "create" modal. This field is pre-populated with a template (default text) for the issue type.

But when we create sub-tasks in a ticket, we never get this populated, which makes sense since it doesn't follow the existing automation flow.

How can I add automation to populate the "default text" of the description field when I create a sub-task on an issue? Important is that we have all issue types available to have as a sub-task type. Example: We can create a story ticket and then create a sub-task on it that is also a story ticket. I want to be able to populate the description text of the sub-task (that can be any type) with it's corresponding default text template that we already have set in our issue rules.


Answers:
author: SpectralScreams
body: * **Using Smart Values or Scripting**:

  * If your Jira instance supports smart values (like {{issue.description}}), you can directly reference the default text template set up for each issue type.
  * If more complex logic or access to Jira's APIs is needed, consider using a tool like ScriptRunner for Jira to write a script that fetches the default text template based on the sub-task's issue type.
* [**Tierbestatter Albstadt**](https://schoenhalde.de/):

  * Test the automation rule thoroughly to ensure that it correctly populates the description field with the expected default text when creating sub-tasks of different issue types.
  * Validate across various scenarios to ensure that the rule behaves as intended without unintended side effects.


author: John Funk
body: Hi Daniel - Welcome to the Atlassian Community!

Not sure I am following completely, but will take a stab at this.

You have a custom field with default text in it. And the works for all issue types except Sub-tasks. Is that correct?

If so, you copy the parent description down to the Sub-tasks after you create the Sub-task using an automation rule, but it will not show during the create process.

comments: author: Daniel Hammerin
body: Hi, sorry if I'm being unclear. I personally find the flows a bit confusing.

I have a custom field on the "create screen"-modal when creating a new issue. I have set up the automation so that it populates the custom field with specific text for each of the issue types. (Bug text for bugs, Story text for stories, etc.)

And what happens is that when I click "create" (submit) in the issue create modal, the automation copies the contents of the custom description field into the "default" description field so what was auto-populated and what was also added manually in the "create-step" now exists in the created tickets description field.

What I am trying to achieve now is that when I go to an existing ticket and add sub-tasks, the created sub-tasks do not get the pre-configured default text that I get in the "create-issue-modal".

I guess my main question is; how I can get "default"/pre-defined text inserted into the description field of a sub-task?

But also, we have it set up so that when we create sub-tasks, we can also select the issue type on that sub-task. So sub-tasks can be, for instance of type: "Story" or "Bug".

I assume that this makes it harder to solve since I can't just make a rule for   
"Issue type == sub-task" and call it a day since the issue type could actually be "Story" for intance.


author: John Funk
body: That helps a lot, but still a little confused. Let's do an example. Issue Story 1 is created with user entered description text of ABC. Then you have rule that is run that updates the Description field to say ABC: 123. Correct so far?

Then you want to create a sub-task under issue Story 1. What is it you want the rule to populate in the Description field of Sub-task 1? ABC? 123? ABC:123? Something else?


author: Daniel Hammerin
body: I create a brand new ticket, called "Story ticket".

When I create this ticket in the create-ticket modal, It uses a custom field called "Story description field". This custom field is automatically populated with a text set by me in the "Fields" section of the Jira project admin settings. It also has all the configs regarding screens, screen-configs and what-have-you.

When I "submit" on the create screen and actually create the "Story ticket", I have an automation set up that copies the content from "Story description field" and puts that into the default "Description"-field.

All good.

When I go into my newly created and submitted "Story ticket" and create sub-tasks in it, I do not get a modal for creating a sub-task. I simply get the one-line field to write a title of the sub-task I am creating.

To the left of the one-line title field, we have a drop down to select issue type of the sub-task we are creating. Sometimes we create sub-tasks of type "Bug", sometimes "Task".

That's fine, no problems.

But what I want is for the "child-ticket" to get the pre-populated text that a "normally" created ticket gets.

Normal scenario:

1. Create issue  
2. Modal opens with pre-populated custom field.  
3. I can edit the custom field  
4. I "submit" and custom field content is copied over to the "standard" description field.

Nice.

Create sub-task scenario: (What I want)

1. Create sub-task  
2. One line create-sub-task-form shows up with: dropdown of ticket type to select and title field.  
3. I enter a title and select ticket type as "Bug"  
4. On submit, The created ticket gets the pre-defined text content that a ticket type of "Bug" is supposed to get in its custom "Bug description field".

Nice.

I know that Since the flow is different from a standard Ticket creation flow, it will not work the same way.

So How can I create an automation rule that is something like:

When issue: Created  
AND issue is child of other ticket.  
Take default-text from custom field and put in field "description"


author: Daniel Hammerin
body: Actually, I just solved it.

One can just create an automation as follows:

When Issue created  
Issue type equals \<type you want\>  
AND: Parent exists  
Edit Issue fields: \<target issue field\> SET: \<Text\>

It works.


Tags: cloud

jira-cloud