ScriptRunner - Behaviour - Error does not prevent to save issue

Marc Minten _EVS_
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.
September 9, 2016

Since we migrated from JIRA 6.3.12, Scriptrunner 3.1.4 to JIRA 7.1.7, Scriptrunner 4.3.5, our behavior scripts that validate field values do not work correctly anymore.

With code

formField.setValid(false)
formField.setError ("Some error message.")

I still see the red message below the field in case an invalid value is entered in the field, but I can save the issue without any further message. The "wrong" value is stored in the issue.

Do I miss something ?

Something changed ?

3 answers

0 votes
Marc Minten _EVS_
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.
September 12, 2016

Hi, I think (!!!) I figured out the case (one of the cases ???) where it goes wrong.

I have a behavior on field Fix Versions, that checks that there is only one version selected in the field, otherwise it raises an error. This works fine, the error message is shown correctly under the field

I also have an Initializer Function in the same behavior, that does several things, among setting the required flag for the field Fix Versions (I have to do this as the flag depend the current state of the issue):

FormField fldFixVersion = getFieldById("fixVersions")
if (...) {
   fldFixVersion.setRequired(true)
else {
   fldFixVersion.setRequired(false)
}

When I comment out just these lines in the initialize function, everything goes fine.

I have the same problem with all fields where I do the combination of

  • setting some flags in the Initializer Function (required, hidden, ..)
  • do a validation on field change

The validation is done and in case the correct error message is shown. But I can save the issue, also with errors in fields.

Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 12, 2016

Seems to be some kind of undesirable interaction - I have created a bug report at https://productsupport.adaptavist.com/browse/SRJIRA-2026... possible workaround on that ticket.

0 votes
Marc Minten _EVS_
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.
September 11, 2016

Hi, I can't see any javascript errors in the console.

In the Behavior, I have several fields defined, they all launch a (their proper groovy) script.

I added debug logging in all the scripts, and can so track what script is launched. When a field is changed, the script attached to that field is launched, and no other one. If an error is entered in the field, the error message is set (see code above), and in the User Interface I see correctly the error message appearing. Then, when I click "Save", no behavior scripts are launched anymore, but the issue is saved with the erroneous values for the field.

How to find out what goes wrong ?

0 votes
JamieA
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.
September 9, 2016

Nothing changed, and we got your support ticket too. Can you check for javascript errors by pressing F12, and make sure you click the "Preserve Log" checkbox so that the log is not erased on navigation.

Suggest an answer

Log in or Sign up to answer