script validator - custom field value

arild marthinussen September 17, 2013

Hi I wan't to add a validator to a transition. Users should not be allowed to pass transition (next status in workflow), unless customvalue field 'DeployedBy" has a value, and user should get a message saying "DeployedBy field must have a value'

I've tried adding validator on the transition

cfValues['DeployedBy'] != 'EMPTY' with errormessage "DeployedBy field must have a value"
Gives no result - pass through the transition even if deployedby is empty, or has a value - no errormsg

cfValues['DeployedBy'] == 'EMPTY' with errormessage "DeployedBy field must have a value"

Throws the errormessage every time, both when DeployedBy field is empty, or has a value

Any ideas ???

3 answers

1 accepted

6 votes
Answer accepted
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 17, 2013

I feel like I should make a t-shirt saying: "What kind of field is it?"

But to check it has some value, you can just use:

cfValues['DeployedBy']

You don't need to compare with the empty string... if it's empty it will be null. Use built-in scripts -> Condition Tester, and asserts (see docs).

0 votes
arild marthinussen September 18, 2013

:-) , 1 mill thanks :-) - it works

0 votes
RambanamP
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 17, 2013

try something like this cfValues['DeployedBy'] == ''

you can check here for script runner validator sample codes

https://jamieechlin.atlassian.net/wiki/display/GRV/Validators

another way is you can use field required validator from JSU plugin(free)

https://jsutil.atlassian.net/wiki/display/JSUTIL/JIRA+Suite+Utilities+Workflow+Validators#JIRASuiteUtilitiesWorkflowValidators-FieldsRequiredValidator

Suggest an answer

Log in or Sign up to answer