script validator - custom field value

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

4 votes

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).

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

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

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,323 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot