Scriptrunner Behaviour: Evaluate description when user changes issue type

Based on the code sample on I have implemented template texts for whenever a user creates a new ticket and chooses "User Story" or "Bug" as an issue type.

Now there is the case where a user starts changing the description text and then realizes, that he has not yet selected the right issue type. So when he changes the issue type now, his custom description text vanishes and is replaced by the new template text. This only happens for issue types where a behaviour is defined for the description field, but not for other issue types.

Is there a way to prevent this?

def desc = getFieldById("description")
def defaultValue = """h3. IST-Verhalten
    h3. Erwartetes SOLL-Verhalten
    h3. Schritte zur Reproduktion
    # Schritt 1
    # Schritt 2""".replaceAll(/    /, '')
if (!underlyingIssue?.created && !underlyingIssue?.description) {

3 answers

1 vote
Steven Behnke Community Champion Apr 11, 2017

I have this issue too, people's descriptions are overwritten when changing the issuetype, regardless of the underlyingissue condition. It evaluates to null when you're on the create screen.

Hi flaimo,

Why the !underlyingIssue?.created condition? I mean all you need to check is if the description field has a value and if it hasn't ( that's what !underlyingIssue?.description does) then add a default one (desc.setFormValue(defaultValue))

The example on your documentation page doesn't take into account the difference between newly created issues and existing issues being opened/edited.


  1. Click "Create"
  2. Select an issue type where a behavior inserts a template text into the description field.
  3. Delete the template text in the description field so that it is empty.
  4. Save the issue
  5. Open/Edit the issue → Not OK: The description field shows the template text again, even though the user explicitly deleted the text.

That is the reason why i do a check if the issue is just being created or if an existing one is edited.


try to use the getFieldScreen() in order to determine in which screen you are. 

Thanks for the tip, but !underlyingIssue?.created actually works fine for the corner case mentioned in my comment, but I still don't know how to deal with the situation in the original posting.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

355 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you