Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

defaultValue for the Description remains after change of ticket type

Salim Hammar August 23, 2024

Hello

 

In my Jira Cloud i have created 2 behaviours for set a diferents description in the system field description in two issue type but in the screen creation when i switch the issue type story to Epic and the description dont change

 

Behaviour n°1 :

Issue Type = Story

Description = “hello set your name : “

 

Behaviour n°2 :

Issue Type = Epic

Description = “give me your reference : “

 

This is my script : 

------------------------------START 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": "👍 Hello set your name : "
        }
      ]
    },
    {
      "type": "table",
      "attrs": {
        "isNumberColumnEnabled": false,
        "layout": "default",
        "localId": "ee831789-6c04-4882-9b22-69e71e2ccfff",
        "width": 760
      },
      "content": [
        {
          "type": "tableRow",
          "content": [
            {
              "type": "tableHeader",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            },
            {
              "type": "tableHeader",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            },
            {
              "type": "tableHeader",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            }
          ]
        },
        {
          "type": "tableRow",
          "content": [
            {
              "type": "tableCell",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            },
            {
              "type": "tableCell",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            },
            {
              "type": "tableCell",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            }
          ]
        },
        {
          "type": "tableRow",
          "content": [
            {
              "type": "tableCell",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            },
            {
              "type": "tableCell",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            },
            {
              "type": "tableCell",
              "attrs": {},
              "content": [
                {
                  "type": "paragraph",
                  "content": []
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
    )
}
}
---------------------------------END SCRIPT-------------------------------------------------
You have idea ?
Thanks in advance

2 answers

1 accepted

0 votes
Answer accepted
Sean Chua _Adaptavist_
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.
August 27, 2024

Hey @Salim Hammar , Welcome to Atlassian Community.

You probably have to do a call to wait for context. Try something like this and see if it works with just words.

const context = await getContext();
const issueType = context.extension.issueType.name;
const descriptionField = getFieldById("description");

let descriptionText;
if (issueType === "Story") { descriptionText = "hello set your name :"; } else if (issueType === "Epic") { descriptionText = "give me your reference :"; } else {
//default text descriptionText = "Any other default description if needed.";
}

descriptionField.setValue({ "version": 1, "type": "doc", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": descriptionText, } ] } ] });

It looks like you are trying to also put in a table there. You can check out the ADF format samples from Create HTML Table with Issue Details .

Hope this helps!

Salim Hammar August 27, 2024

Hello @Sean Chua _Adaptavist_ 

 

it worked, thank you boss ;)

Like Sean Chua _Adaptavist_ likes this
0 votes
Salim Hammar August 29, 2024

Hi @Sean Chua _Adaptavist_ 

 

i would like to set this :

2024-08-29 16_57_22-Document builder.png

 

Can you help me to set this in the script that you have send me , the script for this table generated here : Document builder 

 

this is script you can you generate this table in the link : 

{
"version": 1,
"type": "doc",
"content": [
{
"type": "table",
"attrs": {
"isNumberColumnEnabled": false,
"layout": "default",
"localId": "5c42930a-af01-4057-bd6b-c0fb86e94486",
"width": 760
},
"content": [
{
"type": "tableRow",
"content": [
{
"type": "tableHeader",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "test 1",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
},
{
"type": "tableHeader",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "test 2",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
},
{
"type": "tableHeader",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "test 3",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
}
]
},
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": []
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": []
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": []
}
]
}
]
},
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": []
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": []
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": []
}
]
}
]
}
]
},
{
"type": "paragraph",
"content": []
}
]
}

 

Thanks in advance for your help boss ;) 

Sean Chua _Adaptavist_
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.
September 2, 2024 edited

Hey @Salim Hammar ,

to set the ADF, you can use something like this below. The format doesn't look pretty as I'm just copy pasting from another sample I had, I am generalising for all issuetypes, you will need to set the issuetype requirements etc. 

 

const context = await getContext();
const issueType = context.extension.issueType.name;
const descriptionField = getFieldById("description");

const descriptionContent = {
"version": 1,
"type": "doc",
"content": [
{
"type": "table",
"attrs": {
"isNumberColumnEnabled": false,
"layout": "default"
},
"content": [
{
"type": "tableRow",
"content": [
{
"type": "tableHeader",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Test 1",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
},
{
"type": "tableHeader",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Test 2",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
},
{
"type": "tableHeader",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Test 3",
"marks": [
{
"type": "strong"
}
]
}
]
}
]
}
]
},
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Row 1, Cell 1"
}
]
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Row 1, Cell 2"
}
]
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Row 1, Cell 3"
}
]
}
]
}
]
},
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Row 2, Cell 1"
}
]
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Row 2, Cell 2"
}
]
}
]
},
{
"type": "tableCell",
"attrs": {},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Row 2, Cell 3"
}
]
}
]
}
]
}
]
}
]
};
descriptionField.setValue(descriptionContent);

It should look like this:
image.png

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events