How to add different description templates for different issue types using scriptrunner behaviours (Jira Cloud)
Hello All !
Recently I have been getting several requests from Jira project owners to setup default description templates for different issue types. In this blog post I will go over how to set up different description templates for different issue types using scriptrunner behaviour scripts for Jira cloud.
Writing a behaviour script in Jira cloud is very different compared to writing a behaviour script in Jira data center. Main difference is the language to use. With Jira data center you are limited to using Groovy and with Jira cloud you have the option of using Javascript or TypeScript. Also, below is another major difference with regards to the field that the script is attached to.
A fundamental difference between the ScriptRunner for Jira Server/DC and ScriptRunner for Jira Cloud behaviours feature is that the field selected is the trigger that causes the behaviour to run in ScriptRunner for Jira Server/DC. However, with ScriptRunner for Cloud, you choose an affected field first and then write a script with logic that will alter that field in your preferred way - adaptavist scriptrunner documentation.
Before we jump into creating behaviours, let's define our requirements and assumptions for this blog post.
Requirements :
- When a user selects the issue type "Story" in the project "Atlassian Tools Setup" create issue screen, below text template should be set in the description field.
- When a user selects the issue type "Bug" in the project "Atlassian Tools Setup" create issue screen, below text template should be set in the description field.
- When a user select an issue type other than "Story" or "Bug" in the project "Atlassian Tools Setup" create issue screen, the description field should be empty.
- Scriptrunner for Jira cloud and Scriptrunner Behaviours Forge app is installed on your Jira cloud instance.
Given that Scriptrunner Behaviours Forge app is brand new, it has certain limitations. One of the limitations (as of writing this article) is listening to change of issue type on the create issue screen (if someone comes across this feature, please comment and I will update this post). Given this limitation we will have to create 3 different behaviours to satisfy the 3 requirements we have for this blog post. Two of these behaviours will set a description template for Story and Bug issue types and one will clear the description field if the issue type is Epic or Task.
Now let's go into each behaviour and see how they are setup.

Comments
Post a Comment