Set Parent ID programatically

I have a requirement to provide parent ID when the jira issue is created programatically.

When I set the parent ID, my issue (sub task/sub bug) has to be created under the  given parent ID issue.

Any idea, how can I do this.

I jsut set the issue id long value to my newly creatin issue. But nothing happens.


4 answers

0 votes
Gaston Valente Community Champion Sep 03, 2017


you need to use the subtaskmanager

there are a lot of post in the community with code sample, for example:

If you need more help I think I have a working snippet somewhere

HI Gaston,

Please share... My code not working. Tried a lot.. 

Not sure where you got "parentID" from, but it's not going to work because you might not have it until later if you are running this on "create"

Try using the issue object for the parent:


Hi Gaston,

Thanks for the quick reply. I tried subTaskManager.createSubTaskIssueLink(Issue parent, Issue subTask, User user) API. It says NoSuchMethod. 


And, For Nic, I jsut tried. It creates the sub task issue seperately. But it doesn't create the subtask under the parent issue. 

I do reindex after issue creation too.

Am I doing something wrong..

Thanks Gaston.


I managed to do your way with reflections. That worked! 

Thank you both!!!

0 votes
Gaston Valente Community Champion Sep 04, 2017


This code worked for me:

private void convertToSubtask(MutableIssue issue, Issue parentIssue)
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager()
issue.setIssueTypeObject( subTaskManager.getSubTaskIssueType( this.defaultSubtaskId ) )

subTaskManager.createSubTaskIssueLink(parentIssue, issue, this.runAs)


Keep in mind what Nick said about the timing... 

Great Thanks Gaston. I will try that and let you know how it goes.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

975 views 3 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you