Creating subtasks on an issue
In this recipe, we will see how to create a subtask on an existing issue programmatically.
How to do it...
There are two steps in creating a subtask:
Create an issue object. A subtask is nothing but an issue object in the backend. The only difference is that it has a parent issue associated with it. So, when we create a subtask issue object, we will have to define the parent issue in addition to what we normally do while creating a normal issue.
Link the newly created subtask issue to the parent issue.
Let's see the steps in more detail:
Create the subtask issue object similar to how we created the issue in the previous recipe. Here, the
IssueInputParameters
is constructed (after changing the methods likesetIssueTypeId()
appropriately).For this issue, we will use the
validateSubTaskCreate
method instead ofvalidateCreate
, which takes an extra parameterparentId
.CreateValidationResult createValidationResult = issueService.validateSubTaskCreate(user, parent.getId...