How to use wiki markup in Scriptrunner behaviour script

rneill19
Contributor
October 2, 2024

Hello!

 

I'm using Adaptivist's Scriptrunner for Jira Cloud to create a behaviour that will set the Description field to a default template on the create screen when creating specific tickets. The portion that I'm struggling with is how to write info panels into the description template so that they show like this on the create screen:

 

Screenshot 2024-10-02 at 11.20.55.png

This is the script template that Adaptivist provides:

 

/*
* Note: You should run this script by selecting "On load" in the check box above.
* Note: Only run this example on the Create View as it may overwrite the description field value if run on the issue view.
*/

/*
* Use the format below if your description field is set to use the DEFAULT Text field renderer
*
* const descriptionValue = getFieldById("description").getValue();
*
* if(!descriptionValue.toString()){
* getFieldById("description").setValue('As a <>type of user<>\n I want to <>achieve some goal<>\n So that <>some reason is fulfilled<>')
* }
*/

/*
* Use format below if your description field is set to use the WIKI field renderer
* TIP - To build up the required Atlassian Document format use the Atlassian tool at:
*/

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>"
}
]
}
]
})
Any help here is appreciated, thanks!

2 answers

1 accepted

4 votes
Answer accepted
Max - Swift Checklist Dev
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.
October 2, 2024

Hi @rneill19 ,

 

this format is called Atlassian Document Format and you can play with document Builder 

Just add a panel and it will generate a payload for you

https://developer.atlassian.com/cloud/jira/platform/apis/document/playground/

Screenshot 2024-10-02 at 20.41.31.png

 

{
"fields": {
"description": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": []
},
{
"type": "panel",
"attrs": {
"panelType": "info"
},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "info panel"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "some text in panel"
}
]
}
]
}
]
}
}
}
0 votes
rneill19
Contributor
October 2, 2024

Hey Max,

Thank you so much - that tool is so helpful and exactly what I needed!

Have a great day,

Rachel

Suggest an answer

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

Atlassian Community Events