Jira & Scriprunner Cloud - Set behaviour of a description field value on issue view

Thies Uhlenbruch
Contributor
October 30, 2024

Hey,

I want to set content for a custom wiki description field on view issue behaviour, !not creat.

I have a behaviour script which is doing well on create issue but not on view issue.

Anyone has an idea? :-)

Cheers

Thies

-----------------

// returns DescriptionField
const descriptionValue = getFieldById("customfield_10887").getValue();

//if (statusValue == "10716") {

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

  if (!descriptionValueContent) {

      getFieldById("customfield_10887").setValue(
         {
   "version": 1,
    "type": "doc",
    "content": [
     {
        "type": "paragraph",
        "content": [
          {
           "type": "text",
           "text": "Beschreibung: Die Anforderungen oder die Kriterien, die der IT-Bedarf erfüllen muss."      
         }
       ]
     },
      {
       "type": "paragraph",
       "content": [
         {
           "type": "text",
           "text": "Beispiel: Die mobile App soll eine vertikale Ansicht des Live-Feeds für iPhone-Benutzer bieten, eine Schaltfläche zum Umschalten in die Vollbildanzeige für Desktop-Benutzer haben, einen Link zum Apple Store für Android-Benutzer enthalten und ein ansprechendes Design und eine einfache Navigation haben.",
           "marks": [
             {
               "type": "textColor",
               "attrs": {
                 "color": "#4c9aff"
                }
              }
            ]
          }
        ]
     },
      {
       "type": "paragraph",
       "content": [
         {
            "type": "text",
           "text": "!Den Beschreibungstext sowie den blau hinterlegten Text bitte löschen bzw. durch eigene Inhalte ersetzten!",
           "marks": [
             {
                "type": "textColor",
               "attrs": {
                 "color": "#ff5630"
               }
             }
           ]
         }
        ]
     }
   ]
  })
  }
  }
//}

2 answers

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 1, 2024

Hi Thies,

I can confirm that it is possible to set the description on the issue view (Edit screen), as in Jira cloud, the edit screen is the issue view.

You can do that using the example script named Set default text in Description field.

You will have to remove the if statement of if (!descriptionValueContent) { on line 28 and its closing bracket on line 90 in order to be able to set the value on the view screen.

Please be aware, though, that if a description value already exists on an issue, then it would overwrite it, so the old value would be lost.

This is why the comment exists in the script, recommending running it on the create screen only as a best practice.

I hope this helps.

Regards,

Kristian

0 votes
Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 30, 2024

Hi @Thies Uhlenbruch 

Behaviours only work in Create/Edit screen.

On the view screen, clicking a field with a behaviour opens an Edit screen.

Please check this page: https://docs.adaptavist.com/sr4js/latest/features/behaviours

Thies Uhlenbruch
Contributor
October 30, 2024

Hi @Tansu Akdeniz

thank you but the script doesn't work in edit screen, just in the create screen

Screenshot 2024-10-30 160710.png

Suggest an answer

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

Atlassian Community Events