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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,459,268
Community Members
 
Community Events
176
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

Will C Rising Star May 05, 2022

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

Atlassian Community Events