Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set default ticket description using Scriptrunner Behaviour

rneill19
Contributor
March 19, 2024

Hi!

I am trying to set a default description for tickets in certain projects using Scriptrunner Behaviours. I'm familiar with doing this in Jira Data Center but I'm not sure exactly how it works with Jira Cloud.

I found this script in Adaptivist's documentation:

 

const descriptionValue = getFieldById("description").getValue();

// If description field is wiki markup access the content property
if (typeof descriptionValue !== "string") {
const descriptionValueContent = descriptionValue.content.toString();

if (!descriptionValueContent) {

getFieldById("description").setValue({
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "As a ",
"marks": [
{
"type": "strong"
}
]
},
{
"type": "text",
"text": "<type of user>"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "I want ",
"marks": [
{
"type": "strong"
}
]
},
{
"type": "text",
"text": "<to achieve some goal>"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "So that ",
"marks": [
{
"type": "strong"
}
]
},
{
"type": "text",
"text": "<some reason is fulfilled>"
}
]
}
]
})
}
}

I don't understand where I'm supposed to configure the custom text that I want to appear in the description. Can anyone help? Thank you in advance!

3 answers

1 accepted

0 votes
Answer accepted
Proshkin Kirill September 11, 2024

@rneill19 Hello.
I will try to help you.
I am also use this script to set my own description.
In code I will change some parts for you to understand where to change value.

const descriptionValue = getFieldById("description").getValue();

// If description field is wiki markup access the content property
if (typeof descriptionValue !== "string") {
const descriptionValueContent = descriptionValue.content.toString();

if (!descriptionValueContent) {

getFieldById("description").setValue({
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "YOUR PARAMETERS",
"marks": [
{
"type": "strong"
}
]
},
{ \\ you could delete this part and some lines under
"type": "text", \\
"text": "ONLY IF YOU NEED IT" \\
} \\
] \\
}, \\


Here is an example of one fully working script:

const descriptionValue = getFieldById("description").getValue();

// If description field is wiki markup access the content property
if (typeof descriptionValue !== "string") {
const descriptionValueContent = descriptionValue.content.toString();

if (!descriptionValueContent) {

getFieldById("description").setValue({
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "YOUR REACH TEXT",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
})
}
}

 

rneill19
Contributor
September 18, 2024

Thank you, Proshkin!

0 votes
Nar Kumar C_ - Narva Software
Atlassian Partner
March 20, 2024

Hi @rneill19 

I am a bit biased as I am also an app dev, but personally I do not recommend ScriptRunner Behaviours for issue templates. It comes free with the main ScriptRunner app, but it is super cumbersome and has more problems than it's worth IMO.

If you want issue description templates on create screen, I would suggest alternative apps like ours:

Issue Templates Pro for Jira - Summary & Description Templates

Feel free to reach out to us if you need any help.

0 votes
Harsh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2024

Hi @rneill19 

I would suggest to automation for the same, instead of scriptrunner.
But if you do want to use the scriptrunner would you mind explaining -

- if the description is to be set after the ticket is getting created and if based on some conditions or you want a general description to be set when the issue is created.?

- Or you want a default description to show at the time of creation?

Thank you.

rneill19
Contributor
March 20, 2024

I want the description template to show on the create screen! Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events