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

AB July 5, 2021

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

1 vote
Answer accepted
Ram Kumar Aravindakshan _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.
July 5, 2021

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

AB July 6, 2021

Thank you. I have requested an update for Scriptrunner!

Ram Kumar Aravindakshan _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.
July 6, 2021

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
AB July 6, 2021

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

Ram Kumar Aravindakshan _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.
July 6, 2021

Hi @AB

Glad to hear the solution worked for you. :)

Please accept the answer.

Thank you and Kind Regards,

Ram

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 5, 2021

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("")

AB July 6, 2021

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