Create subtasks as part of Additional fields section using JSON
Asked by David Leal:

I am trying to clone a defect issue type creating a bug issue type using a manual trigger and while cloning initialize some bug fields. The bug depending on the input value from the manual trigger can be created in the same project or in a different one I also added a link to the defect issue type. Everything works fine, but now I want to add subtasks. I need to do it within the same rules because the bug can be created in a different project, so I want to do it as part of the Clone issue action.

Here is for example the JSON file for the case the bug is created within the same project:

```
{
"fields": {
 "customfield_10100" : { "id": "{{severity.get(issue.customfield_10262.id)}}"},
 "customfield_10101" : { "id": "{{type.get(issue.customfield_10264.id)}}"},
 "customfield_10103" : { "id": "{{environment.get(issue.customfield_10266.id)}}"},
 "customfield_10162" : "{{product}}"
},
"issueUpdates": [
{
"fields": {
 "issuetype": {"id": "10003"},
 "project": {"key": "IFR"},
 "summary": "Research Issue"
 }
},
{
"fields": {
 "issuetype": {"id": "10003"},
 "project": {"key": "IFR"},
 "summary": "Implement Fix"
 }
},
{
 "fields": {
 "issuetype": {"id": "10003"},
 "project": {"key": "IFR"},
 "summary": "Validate Fix"
 }
}
]
}

```

When I run the rule **I don't get any error** , the bug is created, with the corresponding values and linked to the defect, **but the subtasks are not created** . For creating the subtasks I took the idea from the[Bulk create issue,](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulk-post)

So the portion of the JSON file that is not working is the action: issueUpdates. Instead of using the project id, I am using the project key, but the rest is the same, removing the fields I don't need to set.

The issue type id is 10003, I got by putting in the browser the following (adding previously a sample temporary subtask to have a subtask section):

<https://MYSITE/rest/api/latest/issue/IFR-532>

and looking to the following portion within the subtask node of the JSON response:

```
"issuetype": {
"self": "https://pan-american.atlassian.net/rest/api/2/issuetype/10003",
"id": "10003",
"description": "A small piece of work that's part of a larger task.",
"iconUrl": "https://pan-american.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium",
"name": "Sub-task",
"subtask": true,
"avatarId": 10316,
"hierarchyLevel": -1
}
```

here is the Audit log of the execution:

![Screenshot 2023-08-27 at 10.40.11 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/277424i2337BED24DBF8947/image-size/large?v=v2&px=999 "Screenshot 2023-08-27 at 10.40.11 PM.png")

and here is the content of the rule:

![Screenshot 2023-08-27 at 10.46.32 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/277425iE4EAA83DD7BF7D20/image-size/large?v=v2&px=999 "Screenshot 2023-08-27 at 10.46.32 PM.png")

Here is the portion of the rule for the case of generating the bug within the same project:

![Screenshot 2023-08-27 at 10.50.24 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/277427i1B66CF40D91AAD89/image-size/large?v=v2&px=999 "Screenshot 2023-08-27 at 10.50.24 PM.png")

Here is the bug generated:

![Screenshot 2023-08-27 at 10.53.28 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/277429i7E686CFC13CF1405/image-size/large?v=v2&px=999 "Screenshot 2023-08-27 at 10.53.28 PM.png")

Any help is appreciated. Thanks in advance.


Answers:
author: Darryl Lee
body: I don't believe you can create subtasks via JSON. You probably will need a second rule to create the subtasks. Here is a good solution describing this:

* [Clone Epic, Stories and Subtasks tree with Jira Automation](https://community.atlassian.com/t5/Jira-articles/Clone-Epic-Stories-and-Subtasks-tree-with-Jira-Automation/ba-p/2316387)

comments: author: David Leal
body: [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) this is what I did, as a workaround, but according to the REST API specification we can use the section issueUpdates to be able to do a bulk update for issues, I am surprised that the rule doesn't generate an error, so the syntax seems to be correct, but the subtasks were not created. Thanks!


author: Darryl Lee
body: OH! I found the **issueUpdates** you were talking about. It's part of:

* [Jira Cloud platform / Reference / REST API -\> Bulk create issue](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulk-post)

That's cool!

***Unfortunately*** that is a different API call than what I think Automation gives us access to, which is the only as part of an issue Update/Edit. So only these options would apply:

* [Jira Cloud platform / Reference / REST API -\> Edit Issue](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put)

I will say that in the past I've found out the hard way that sometimes the absence of an error does not necessarily mean it's correct.