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

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

Scriptrunner Behaviour: defaultValue for the Description remains after change of ticket type

Good day,

I have created a Scriptrunner Behaviour to fill the field "Description" with a text template when a issue type "Request" is created:

- Guide workflow is adapted
- Initialiser is empty
- Optional/Writeable/Shown not changed
- Conditions changed to Workflow Action "Create"

and the server side script field is filled with the usual script to add text to the description field.

My issue:

- In JIRA I click "Create" to create a new issue.

- The ticket type is set to "Request" because this was the type of the last issue typ I've created.

- The description is filled by default with the server side script of the Behaviour.

- But I want to create a story, so I change the issue type to story.

- Problem now: The issue type is changed, but the description template remains.

My expection:

When I change the issue type the description field should be empty again.

 

I hope someone has an idea to fix that :-)

Thank you!

2 answers

1 accepted

Hi @AB

Quick question, have you edited the default Description template before changing the issue type?

If so, then the template will not be removed. This is an expected Behaviour.

However, if you switch from the Request issue type to another issue type without updating the Description template, the Description field will be cleared. 

If you are currently using a ScriptRunner version before 6.26, I would advise you to update it to the latest release as there was a bug fix related to this issue.

For more information, you can visit this bug report SRJIRA-3970 as well as SRJIRA-5276.

Before version 6.26, the description field template will not be cleared when switching issue types, even if no modifications were made to it.

I hope this helps to answer your question. :)

Thank you and Kind Regards,

Ram

Thank you. I have requested an update for Scriptrunner!

Hi @AB

The approach you are taking in your comment below will not work.

Suppose you still intend to clear the Description field even though the template has been updated. In that case, you will need to create a separate behaviour configuration and specify the project you do not want the template to display. 

And, in the Initialiser, you will need to include this code:-

def description = getFieldById("description")
if(actionName == "Create") {
  description.setFormValue("")
}

This is the workaround that I have provided in the SRJIRA-3970  ticket.

I hope this helps to answer your question. :)

Thank you and Kind Regards,

Ram

Like AB likes this

I have checked the issue on the test environment where the latest version of Scriptrunner is installed and it works there.

Hi @AB

Glad to hear the solution worked for you. :)

Please accept the answer.

Thank you and Kind Regards,

Ram

Hi @AB  Welcome to Atlassian Community!

You have to define value for other issue type using else as well otherwise description remains for other issue types.

Put else condition here :- 

def desc = getFieldById("description")

else {
desc.setFormValue("")

Hi!

My script looks like this:

def desc = getFieldById("description")

def defaultValue = """\

(text)

""".stripIndent()

if (!desc.getValue()) {
desc.setFormValue(defaultValue)
}

So - would this be correct?

def desc = getFieldById("description")

else {

def defaultValue = """\

(text)

""".stripIndent()

}

if (!desc.getValue()) {
desc.setFormValue(defaultValue)
}

Suggest an answer

Log in or Sign up to answer
TAGS

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