I have to check, if a field contains a 4-digit number (Project-ID). As this seems not to be possible out of the box, I try to achieve this with a custom field and script-runner. I also found an interesting page https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/simple-scripted-validators.html, but I nowhere in Jira (Software, Server) find this view.
Can please someone lead me to this view?
Is there a better way to validate fields?
Have you got Script Runner installed?
If you have, then try going back to the workflow and add a validator, then check the list of types of validator do you get the scripted validator option on the list?
Hi Nic
Thanks for help.
Script Runner is installed.
I open <JIRA Administration><Issues><Workflow> and select the workflow of one project. On a transition I then can add a validator. If I select 'script validator' and 'Simple scipted validator' there is the missing view :)
Do I have to do this for every transition in every single project? Is this only checked, if there is a transition (and not on 'Save')?
and last: 4 digits numeric-Test - which language is used? would this work?
cfValues['field'].lenth() == 4 & isInteger.(cfValues['field'].value)
Sorry, I need realy basic support.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>Do I have to do this for every transition in every single project?
Transitions are not part of a project directly, they are part of a workflow (they can be used multiple times in a workflow though). If a workflow is used by several projects, then you will affect all of them just by changing that single workflow, but if your projects all use different workflows, then yes, you're going to have to go into each workflow to edit the transitions that need changing.
>Is this only checked, if there is a transition (and not on 'Save')?
I don't understand the question. A validator runs when the transition it belongs to is committed to by a user, if that helps explain though.
>4 digits numeric-Test - which language is used?
Groovy and/or java are easiest to use in script runner
>would this work?
I think so, barring the spelling mistake. I've not used isInteger like that before, but it looks right.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's working :)
I understand the meachanism and I'v learned a lot - but it's not done.
The validation should be done on 'every' update (save) to the issue and not only on workflow-transitions.
Back to my second question >Is there a better way to validate fields?
Additional Infos:
The defined Error Message is only shown, if no Field is defined and it's always a PopUp - no need to handle in the moment.
Working Condition for Simple scripted Validator:
String myPJ = cfValues['PJ-ID']; if (myPJ.length() == 4 && myPJ.isInteger()) { 1 == 1; }
I'm pretty sure there are better possibilities, but it works fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.