Validating data before saving issue in Jira 5

Andrej Gregorka February 1, 2012

Hello, I'm trying to write plugin to validate data before saving an issue. I don't want workflow validation, but validation before saving.

I'm not really sure with what kind of plugin module I can do that. How can I catch the data just before it is saved and then reject the saving in case data does not match the required criteria?

1 answer

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.
February 1, 2012

You just want a standard validator module... https://developer.atlassian.com/display/JIRADEV/Workflow+Plugin+Modules

That validates data before saving. Not sure what you mean by saying you don't want workflow validation.

Andrej Gregorka February 1, 2012

Hello Jamie,

I mean that I want to perform validation right away when user changes the content of some filed. If the content is not right the changes should not be made to the issue.

From what I see workflow validation is performed when issue changes its state in the workflow. I want the validation to work even if the workflow transitions are not made.

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.
February 1, 2012

Hi Andrej,

OK... your options are using javascript then, or, this is what the behaviours plugin was written for: https://studio.plugins.atlassian.com/wiki/display/JBHV/JIRA+Behaviours+Plugin .

Andrej Gregorka February 1, 2012

Hello,

I have also installed the Behaviours plugin, but I was unable to use it on Jira 5. I get an exeption when clicking the "Fields" link when editing new behaviour. I see somone had already entered an issue about that: https://studio.plugins.atlassian.com/browse/JBHV-100

I tried downloading the source of Behaviours plugin too and compiling it myself but I'm not able to get it to work at all in that case. I don't get any errors during compilation, but when I install the JAR into Jira the first thing I see is that there are only 17 modules in the plugin while the binary version has 18. When I try to go to behaviours panel I get an exection right away, before I even see the "Fields" link.

I may not be building it correctly, I'm building it with JDK1.6.0_25 and atlassian-plugin-sdk-3.7.2 using the following commands to create the JAR file:

atlas-compile.bat
atlas-package.bat

Andrej Gregorka February 1, 2012

From what I see the following line is missing at the start of the the getAllFields function in ViewBehaviours.groovy file:

ComponentManager componentManager = ComponentManager.getInstance()

The problem is, i'm not able to install the plugin that i build myself correctly, so either i'm doing something wrong when building it or something is missing from the source.

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.
February 1, 2012

Yes you're quite right... I forgot you were using jira 5. I will be updating this shortly.

I don't think you're building it wrong, it's just that I don't think it's compatible with rc3... it was working for beta2. Will get back here when I can.

Andrej Gregorka February 1, 2012

Thank you very much for your answers Jamie. I will wait then till the new version of Behaviours plugin comes out.

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.
February 2, 2012

I'm still testing and this won't be the final version for jira5, but I've attached a (more) working version to https://studio.plugins.atlassian.com/browse/JBHV-100.

Suggest an answer

Log in or Sign up to answer