How do I create a sub-task for the current issue with firstSync?

Originally asked by Mirko Balke on 28 October 2020 (original question)


Sorry, my English is bad.

I hope you understand my question anyway. :slight_smile:

I would like to create a sub-task for the current issue during firstSync.

This sub-task should be linked directly to the parent issue.

Is there a script / rule example for this?

I work with Jira and Jira Service Desk.

Best Regards,
Mirko


Answer by Juan Grases on 30 October 2020

Hi!

I don’t have the exact script in hand but I wanted to make you aware that from the scripts, you have access to all the Jira Java APIs that allow you to do this kind of actions. If you are familiar with script runner then you will have some experience with writing this kind of scripts. For example to get the IssueService service from the script, you can do something like:

def is = com.atlassian.jira.component.ComponentAccessor.getIssueService()


You could use this issue service from Atlassian to create an issue, setting a parent Id. I would even recommend to look for “Creating subtask” on script runner docs, as the scripts you will find will also be valid for exalate, I have found this: https://community.atlassian.com/t5/Jira-questions/Scriptrunner-Create-Subtask-for-a-task-which-is-created-by-quot/qaq-p/885501

Hope this helps :smile:

Juan