We have a new documentation site. Please go here to see the latest.
Create issues from checklist items on issue transition
This guide is based on ScriptRunner for Jira provided by Adaptavist. Please make sure that ScriptRunner for Jira is installed in your Jira first.
The guide works for Classic projects only. Next-gen projects are too limited at the moment.
Prerequisites
- "Save checklist data to Jira custom fields" option must be enabled in Issue Checklist Global Settings.
Guide
Here is a step-by-step guide how to add a "script listener" which on issue transition to specified status will read checklist from YAML custom field and create issues corresponding to checklist items using Jira REST API.
- Navigate to "Jira settings > Apps > ScriptRunner > Script Listeners".
- Click on "Add Listener". An area with a form will be shown. Enter a name of the listener, select "Issue Updated" as an event on which the script will be run and optionally select a project. Select "Current User" on the right side if you want the reporter field of the newly created issues to be set to the user who transitioned the original issue.
Also on the right side is an editor field. Enter the following Groovy code into it:
The comments in the script describe some changes that one may want to introduce, for example changing the type of the issues to be created. If you want to ensure the issues will be created only once, either use an issue property or clear checklist as part of the script.
- Adjust the script to your needs and save it.
Please note that:
- The script ends execution if there was no issue transition or the transition was to another status than the status (or statuses) expected by the script ("Done" by default). Make sure to change the expected statuses in accordance with your workflow.
- The script can also create issue links between newly created issues and the parent issue. The code doing that is commented out by default so uncomment it first. You may want to change the issue link type and the relation between issues (inward / outward link).
- By default, no issues are created for checklist separators. This can be easily changed by commenting out a single line in the script.
- After the issues are created the script can mark items as completed by updating Checklist Text custom field. If you wish to do so, uncomment the last lines in the script. It is also necessary that either the custom field is present on the issue screen or the script listener is run as ScriptRunner Add-On User.
- That's all: by default, the script should create issues of type "Task" from items that are not checklist separators after the original issue was transitioned to status "Done".
If you need help with troubleshooting any potential problems with the script listener, please add entry logs with more information to the ScriptRunner log (e.g. content of items variable). Next, after script execution, navigate to "Jira settings > Apps > ScriptRunner > Logs"