Set Parent key for subtask in Advanced mode in Automation for JIRA
Asked by Romain VELON:

Dear Community,

I am trying to create an automation rule to transform a "Task" issue type in a "subtask" one when this Task is linked to another parent issue.

++**Trigger**++ : when a link is created between 2 parent issue - 1 of type Enhancement and 1 of type Task

++**Then**++ I would like to transform the Task into subtask of the Enhancement.

![image.png](/t5/image/serverpage/image-id/109536i3DBB06E7714B1D99/image-size/large?v=v2&px=999 "image.png")

I'm using the "Edit fields" action to change the issue type. "Parent key" is not available as a field to be set. So I try it in the advanced mode.

This Automation is not successful, I should have something wrong in my JSON in Advanced mode.

![image.png](/t5/image/serverpage/image-id/109537iA14D8F30E188BC2E/image-size/large?v=v2&px=999 "image.png")

Error I get is "Issue type is a sub-task but parent issue key or id not specified. (issuetype)"

Thank you for your help.

Romain


Answers:
author: JD
body: Hi [@Romain VELON](/t5/user/viewprofilepage/user-id/1052889) ,  

We currently don't support converting "tasks" to "subtasks". This operation can often require an "issue move" operation which involves field/workflow mapping depending on your setup (if you go to your task click the "..." and hit convert to subtask you'll be taken through the remapping).  

As mentioned above the alternative is to use the "Clone issue" action, set the issue type to subtask and the parent issue to trigger issue (and then clean up the old task).  

Hope that helps,  

John

comments: author: Romain VELON
body: Thank you [@JD](/t5/user/viewprofilepage/user-id/1240728) , I will proceed that way.


author: Nic Brough -Adaptavist-
body: The parent key is not "just a field", it's a structural thing and can't be just set, you have to use something that can change the linked parent. I don't think you can do this in a simple Automation "edit fields"

comments: author: Curt Holley
body: I agree with Nic. I don't believe you will be able to change the issue type....you could make a copy of it as a sub-task (with its own unique key) and then delete the 'task'. But It's all getting a bit complicated


author: Romain VELON
body: Thank you [@Nic Brough -Adaptavist-](/t5/user/viewprofilepage/user-id/781454) , [@Curt Holley](/t5/user/viewprofilepage/user-id/3527535) , I was pretty sure it would not be possible.

Copy it as a subtask was my second option, I'll try it.


author: Richard Vencu
body: I was able to convert an issue to a subtask, just not sure what field to update to specify the parent. If subtask and issues are both using the same workflow it seems feasible.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/114666iBCA80BBDDA008F8E/image-size/large?v=v2&px=999 "image.png")

comments: author: Richard Vencu
body: OK, got the same error as mentioned here.

If there is no attempt to set up the parent key then the issue can be converted to subtask but it is not linked to any parent so probably not very useful. Going to explore the clone issue route as well.


author: Curt Holley
body: Question [@Romain VELON](/t5/user/viewprofilepage/user-id/1052889) the "Parent to child relations" in your trigger....is that a link type description you have in Jira? As i don't see that option, only link types that we have set up in our instance.

I only ask as I was looking the other day for a way to trigger from changes to the Advanced Roadmaps "Parent link" filed.

comments: author: Romain VELON
body: Hi [@Curt Holley](/t5/user/viewprofilepage/user-id/3527535) ,

Yes this is a link I created on the instance.


Tags: cloud