I would like to create an Issue in a workflow postfunction, very simple. However, I also want to create sub-tasks in the created Issue. Can that be done with scriptrunner or some other tool?
Community moderators have prevented the ability to post new answers.
Create your subtask(s) like any other issue (setting the necessary attributes, such as issue type [a type that is a subtask]), and then use the following bit of coding to link it to its parent. I'm not sure that both are necessary; I used them both when I scripted subtask creation a while back.
While setting the subtask attributes, use the setParentObject() or setParentId() method: https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/MutableIssue.html#setParentObject-com.atlassian.jira.issue.Issue-
After creating the subtask issue, link it to its parent with the createSubTaskIssueLink() method in the SubTaskManger class: https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/config/SubTaskManager.html
Yes, there are a number of tools you can add to Jira that can do this sort of thing.
A starter for Scriptrunner is probably https://library.adaptavist.com/entity/create-sub-tasks-when-an-issue-is-created - I usually steal that and extend it.
If you do decide to do this with SR, then remember that you'll need to create the main issue first, then add sub-tasks to it later. The parent issue needs to exist for the sub-tasks to be attached.
I mean, if you have a script that does this:
It is likely to fail. Your script should be more:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.