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 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.

2 answers

I ran into this Problem as well.
Even had to set the description to be empty for every project and issue type because it did not clear itself, when switching during the "Create" screen (which in turn also produced the warning).
After a lot of trail and error, i discovered the Problem.
I copied the Text, for the default value out of a jira field and it had three points in it ("..."). Those three points somehow got interpreted a special char, that looked like three points. I am pretty sure that char caused the problem of the form value not clearing itself.
Don't know why and don't know how.

So make sure the text, that you are setting the default form value to, does not have any unexpected chars in it!

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

 

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.

Suggest an answer

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

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

97 views 1 6
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