Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Clearing default text in description field : behaviour plugin

I have created a behaviour using behaviour plugin for populating default text in Description field while creating an issue. Mapping is for a Project say "Project A" and issue type "Change Request".

Behaviour works fine for correct selection of the Project and Issue Type. However to make it more appropriate, the default text should get clear on selection of the different issue type which does not happen with the current script.  Can anyone help me with achieving this behaviour?

Following is the script i am using in the Initialiser.

def desc = getFieldById("description")
def defaultValue = """Example Text """
if (getActionName() == "Create"){
else {


Thank in Advance.


5 answers

1 accepted

3 votes
Answer accepted

Instead of putting the script in the initializer, I'd put it in a server-side script on the Issue Type field. To remove your added text whenever someone switches to/from the issue type, the best thing to do would be to get the currently input value and just use a .replaceAll to remove the example text.

You can limit this behaviour to a particular project when you setup the mapping.

Also, as a side note, I thought I'd make it so the default value gets prepended to the description. That way, if they've already entered something when they switch between issue types, their other text doesn't get overwritten.

def desc = getFieldById("description")
def issueType = getFieldById("issuetype")
def defaultValue = """Example Text """
def currentValue = desc.getFormValue()
Replace 100001 with your issue type's ID; 
Alternatively, you can use the IssueTypeManager class to get the ID 
based on the Issue Type's name and other properties for clarity, and to 
harden the script against Issue Type changes later
if (issueType.value == "100001"){ 
      desc.setFormValue("$defaultValue - $currentValue")
else {
     desc.setFormValue(desc.value.toString().replaceAll("Example Text ", ""))

This does have the drawback that someone might type in "Example Text" themselves and see it removed. That said, it will preserve anything they put into the description field that wasn't the phrase "Example Text".

Note: I'm assuming that you have updated to a version of ScriptRunner that includes Behaviours as a feature, and aren't using an old version of the separate Behaviours Plugin.

Thanks for the prompt response. Yes, I am using Script Runner which has Behaviour as feature.

I think I have not clarified the requirement properly. Sorry for the confusion.

Above suggested script by you replaces the "Example Text" on the action other than "Create", but i do not want that. I want to clear the default text i.e. "Example Text" on 'Create' action only when I change to different Issue Type than Change Request on the same pop-up screen. I have mappings for a project and Issue Type Change Request.

That makes more sense... I just sort of assumed the "if" condition was the one you wanted, and didn't look too closely! smile

I've updated my answer.

I found my mistake that in the mapping section i was mapping with Project and only one issue type"Change Request" which was making not to trigger script when there is a selection of different issue type. I made the changes and script works fine.

Somehow desc.setFormValue(desc.value.toString().replaceAll("Example Text ", ""))didnt work for me.. but the basic functionality was enough for me for now so will investigate why it is not working for me. If you could guess any errors, please let me know.

Thanks Jonny for your help. Much appreciated. Have great time smile

@Suhas P What changes did you made here?

Currently, I am also facing the same problem and mapped it to my Project and a particular issue type. Why is it wrong?

@Sanket Mane you should add additional condition for issue type along with getActionName() == "Create"  as below. and I use this code in initialiser.

In mapping use a project and All Issue Types (not a specific issue type), then the code will run for every issue type selection and set or clear the description based on the issue type selection.

def desc = getFieldById("description")

def defaultValue = """Example Text """
if ((getActionName() == "Create") && ( =="Task")){
else {

Beware that clear field will clear the description field completely . So you can use it or you can also combine it with the login given by Jonny above in the answer with replaceAll to clear only default text and keep the other text. Depends on you how you want.

@Suhas P

This seems to have helped but caused another issue. Due to the implementation of this behaviour- whenever we try to edit the description field- it doesnt show the required content inside it. I see all the content on the View Screen but when I click on the edit screen Description field appears to be empty.

Can you help me on it. 
Thank you 

@Sanket ManeOhh I think its because of the Else statement. Modify the Else statement like this 

def desc = getFieldById("description")

def defaultValue = """Example Text """
if ((getActionName() == "Create") && ( =="Task")){
else ((getActionName() == "Create") && ( !="Task")){
else {


Like Dave Liao likes this

I have the same problem. The "description"-field has two display mode: Text and visual.

If you stay in the "Text"-Mode, then the field gets updated correctly, but if i am in the "Visual"-Mode then the description field gets not updated.

Do you have an idea how to force the update of the visual mode?

Like Christophe Paquignon likes this

@Martin Bischof did you find solution for your problem? I am facing the same issue when in visual mode behaviour code is not firing.

Hi everyone,

I have the same problem, Description field doesn't clean up when the conditions of the behaviour are not fullfilled.

I have tried all suggestions which are in this thread, but none works. Could you please help me to solve it?

Thanks  a lot in advance.

I have been able to fix it.

I have mapped the project with all issue types and I have add in the script the following conditional in order to remove the description field:

if ( == "Bug") { 
}else {

Once applied it, when I choose one of my projects and select an issue type different of Bug, my description field is cleaned up.

I hope it helps.


Like # people like this

Sir, you just made my day!

Works like a charm! Thank you!!

Got similar issue, will revert back if I found anything

Ok, my requirement was :-

I need to set a template description for a specific Project and Issue type, and if a user chooses a different issue type, the description should remain blank.

so here's what worked for me (you can easily tweak this for your requirement)


def desc = getFieldById("description")

def defaultValue = """
* *LINE 1*
**  line 1.1

* *LINE 2*
**  line 2.1


def des = desc.getValue();
if ((getActionName() == "Create") && ( =="Story") &&
!desc.getValue().toString().contains("LINE 1") &&
!desc.getValue().toString().contains("LINE 2")){

desc =getFieldById("description")

if( !="Story" &&
desc.getValue().toString().contains("LINE 1") &&
desc.getValue().toString().contains("LINE 2")){
desc.setFormValue(" ");

And need to map it to *All fields*

I have a questions about it:


I use this script on my jira and it works very well!
But, when I will go to edit some issues all the information in the description field desapear:
How can I solve this?epictemplate.PNG

You should use getActionName() == "Create" in the condition so script won't clear the description on Edit action.

Like # people like this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

☕️ Monday coffee with Jexo: Weekly Atlassian news roundup | 21st June 2021

Hi community 👋, as every Monday we're bringing you a quick update on what happened in the Atlassian ecosystem last week. There were a few interesting events like for example the announcement of th...

53 views 0 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you