ScriptRunner Behaviours - default description overwritten

Sasha Solig
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 18, 2020

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

2 votes
Tiago Miguel Sousa Santos
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 21, 2022

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

Will C
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2022

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

0 votes
Maximilian Seidler August 11, 2021

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

 

Maximilian Seidler January 27, 2022

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.

0 votes
Dennis Schamne May 12, 2021

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

Sasha Solig May 14, 2021

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.

Dennis Schamne February 10, 2022

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
AUG Leaders

Atlassian Community Events