Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,862
Community Members
 
Community Events
165
Community Groups

ScriptRunner Behaviours - default description overwritten

I have a problem with an initialiser behaviour setting the default description. Note that this only occurs when the create issue screen is in full screen mode (not modal dialog box mode). The way I navigate to the create issue screen in full screen mode is via an external link from our intranet with the project and issue type ids included in the URL e.g. https://jira.acme.com/secure/CreateIssue.jspa?pid=14600&issuetype=12803.

The problem we are seeing is the modified description text is being reset to the default value configured in the behaviour when one or more mandatory fields are not completed prior to the Create button being clicked. Further, a popup is displayed with the heading "These fields have default values for this project and issue type combination. We have preserved the existing values in case you need them." and the modified default value below.

Users are not seeing or understanding this message and are submitting requests without the required (modified) description text that was lost on the first create attempt.

Note that the description behaviour script is as per ScriptRunner documentation.

I have added code that detects that the on-screen value is different to the default value and in such cases will avoid overwriting it (see below), HOWEVER, it in turn causes another problem: it prevents the description from resetting when the project or issue type is changed (this time in modal dialog box mode). In this case (when the project or issue type is changed), we DO want the description to reset to the desired default value (or blank when there is no default value). Catch-22!

if (!underlyingIssue?.description) {
   if (desc.getFormValue()) {
      desc.setFormValue(desc.getFormValue())
   }
   else {
      desc.setFormValue(defaultValue)
   }
}

I realise this is a very edge-case scenario, but any ideas would be gratefully received.

3 answers

I had such a similar Warning but I solved my problem by adding a space between my * and to all occurrences

Previously my default Description was:

*Story Description*:

then changed it to

*Story Description* :

Maybe check if at the end or the start of any special formatting character there is a space in between them

Very weird, but this has sorted it for me too, I didn't think having *: together would cause issues.

I ran into this Problem as well.

Make sure the text, that you are setting the default form value to, does not have any unexpected chars in it! That caused a Problem for me.

Here is how I set the form values: (only one behaviour for each different case)

sleep(100)
if (projectKey == "AKEY" && relevantIssueType) {
getFieldById("description").setFormValue("default description for A")
}
else if (projectKey == "BKEY" && relevantIssueType) {
getFieldById("description").setFormValue("default description for B")
}

 

The behavior of the "These fields have default values for this project and issue type combination. We have preserved the existing values in case you need them." warning is very strange and inconsistent.

While this leads to the warning message:

* *Some bold list item*:

this does not:

* *Some bold list item:* 

 Note, that its just the colon being inside of the bold section. Again, I have no idea why.

Have you been able to find a clean solution to prevent the popup with the message about the default value?

Sorry Dennis I have not. If it weren't for the inability to add default values for system fields in Jira, we wouldn't need this hacky workaround in the first place.

Here's a workaround, that costs money: JEditor

With JEditor, you can create templates and use them to be automatically inserted into fields (prepopulation/autofill).

Downside: For this to work, the field renderer has to be changed to use JEditor. This means from now on, that field will use HTML formatting instead of Wiki Mark-Up.

Though you can configure JEditor to use autofill also for Wiki-Renderer fields (by enabling a special module), but it is not working very well: on the create screen the text will not show up in Visual mode even if it can be seen in Text mode.

Suggest an answer

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

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

336 views 0 7
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