Skip to main content
Example scripts
arrow icon
To homepage
Jira
Cloud icon
Cloud

Set a default description when an issue is created

Features
Behaviours
Created 1 year ago, Updated 1 month(s) ago
App in script
ScriptRunner For Jira
ScriptRunner For Jira
by Adaptavist
Compatibility
compatibility bullet
Jira
Language |
typescript
const descriptionValue = getFieldById("description").getValue();

// Check if the description field is a wiki markup type field
if (typeof descriptionValue !== "string") {
    const descriptionValueContent = descriptionValue.content.toString();

    // Only set the field if it does not already have a value
    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>"
                        }
                    ]
                }
            ]
        })
    }
}
Having an issue with this script?
Report it here