Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

What should script validator give back?

MrDanielKing August 23, 2018

I would like to write a script validator. It should summarize some number from  a  database, and if the sum is big enough the user can go into the  new issue status, otherwise it should give back an error msg.

I wrote the code and it do the summerizig, and the if well, but i couldnt find anything about what i should give back to the validator.

Its JIRA v6.2.3.

 

Thanks for help,

Dani!

1 answer

0 votes
Tarun Sapra
Community Champion
August 23, 2018

Hello @MrDanielKing

The validator only gives back error in case the validation failed scenario occurs otherwise it doesn't do anything.

Please see sample here

https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/require-fix-version-if-fixed.html

In case you want to throw error and stop the transition then throw the following exception with a custom msg

throw new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of 'Fixed'")
MrDanielKing August 23, 2018

Thank you @Tarun Sapra but i have not acces for the scriptrunner, so i think i cannot use the InvalidInputException.

However you say, if the result is good, so the issue status is changeable, i dont have to give anything back to the groovy?

Tarun Sapra
Community Champion
August 23, 2018

If everything is good then no need to return anything,, only throw exception if an condition test fails like the sample in the link which I shared.

MrDanielKing August 23, 2018

Thank you! :) I will test it asap! :)

Suggest an answer

Log in or Sign up to answer