Forums

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

Create subtasks as part of Additional fields section using JSON

David Leal
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 Champions.
August 27, 2023

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,

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

and here is the content of the rule:

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

Here is the bug generated:

Screenshot 2023-08-27 at 10.53.28 PM.png

Any help is appreciated. Thanks in advance.

1 answer

1 accepted

2 votes
Answer accepted
Darryl Lee
Community Champion
August 27, 2023

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:

David Leal
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 Champions.
August 28, 2023

@Darryl Lee 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!

Darryl Lee
Community Champion
August 28, 2023

OH! I found the issueUpdates you were talking about. It's part of:

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:

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.

Like • Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events