how to validate custom field(user picker filed) with simple script validator


Using simple script validation, i want to validate if a custom field(user picker field) is empty, show error message.

I tried below code, it always shows msg, even when customfield has user in it.

cfValues['customfield_10000'] = null

I tried many combinations of above with custom field name etc, still same issue.


5 answers

1 accepted

With a simple scripted validator, you just need:

If you want to ensure it's empty use:
! cfValues['customfield_10000']


I tried with this script -


it gives message even there is value in custom field( user picker field)

this script -

! cfValues['customfield_10000']

does not give any message, if there is no user in custom field


Thanks for quick response, sorry if there was any confusion.

Let me explain the scenario :

while doing the transition, check the validation

If CR user( customfiel_10000) is empty, show msg to user to select a user in custom field, and dont allow the tranisition.

If CR user already there in field, dont show a msg, allow the transition.

@Jamie Echlin [Adaptavist],

I am using the script validator on the create transition and I want to build my condition based on the value of a user picker custom field and another select list custom field. I have two problems, the first is how to capture the value of the custom field on create transition and how to compare the value of the user picker custom field to a certain value. My script should be in this form:

if (cfValues['Some Custom Field'] == 'Some Value' and cfValues['user picker field'] != 'xxx') return false; else return true;

i think you have to try some think like this

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.crowd.embedded.api.User

MutableIssue issue = issue
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField customField = customFieldManager.getCustomFieldObject("User Custom field Name")

def fieldVal = issue.getCustomFieldValue(customField)
   if(fieldVal == null ){
  //throw error message here

Hi R Prasad

Thanks for the reply, i tried with this code, i still get error msg, when custom filed is NOT null!!

can you share what is the error message you are getting?

Hi Prasad

I am using JIRA 6.0.2, here is the catalina.out error.

on screen, it shows message " A Code reviewer must be assgined before intiating code review" even when code reviewer is present in the field( not null), not able to tranistion issue with message.

2013-09-06 11:34:39,294 http-bio-9000-exec-41 ERROR xxxxxx 694x76840x1 1tnseum /secure/CommentAssignIssue.jspa [atlassian.jira.workflow.OSWorkflowManager] Caught exception while attempting to perform action 881 from workflow 10641 on issue 'DEV-74'

[InvalidInputException: [Error map: [{}]] [Error list: [[A Code reviewer must be assgined before intiating code review]]]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.codehaus.groovy.reflection.CachedConstructor.invoke(

at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(

at org.codehaus.groovy.runtime.callsite.ConstructorSite.callConstructor(

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(

at com.onresolve.jira.groovy.canned.workflow.validators.SimpleScriptedValidator.doScript(SimpleScriptedValidator.groovy:66)

is there any validators/functions configured on that transitions?

NB - rambanam's answer relates to using a standalone groovy script. With the "simple scripted validator" you just provide a statement that evaluates to either true or false, and provide the error message. You don't need to worry about throwing the exception.


There are no other validations on this transition. this is onky validation i was adding as a simple script validation in that transition.

@ Jamie

oh ok, let me try with groovy script

i tried with Prasad code as a behaviour, it did not show any msg to user, when custom field is empty.

Maybe it s a good place to add my question here as we want to check something very similar:

If one custom field (Patch Type) is of a specific value (Patch) another custom field (CEMLI) is not allowed to be empty. In case the expression is true prevent of the transition (Create Issue) and show a message (Please choose according CEMLI) to the user.

cfValues['Patch Type'] == 'Patch' && ! cfValues['CEMLI']

The result of this is that no issue can be created as the message is shown at any combination of values. Anybody an idea what to be changed?

If Patch Type is a select list, it should be:

cfValues['Patch Type'].value == 'Patch'

Hey Jamie,

thanks for being quick, but unfortunately this don t work! I adapted your suggestion to the one below as CF-Type of "Patch Type" is single select list, the CF "CEMLI" is of Type "Select List (multiple choices)".

cfValues['Patch Type'].value == 'Patch' && ! cfValues['CEMLI'].value

This expression blocks everything, i assume the expression doesn t match to the multi-select list?!

Update: Tested with only

cfValues['Patch Type'].value == 'Patch'

doesn t block anything... *confused*

Try the two parts separately in the admin -> built-in scripts -> condition tester.

That I was quick was just pure coincidence by the way.

I have multi select list custom field. If i select perticular option script should make two fields required on same screen.How we can achive this.

It's just a variation on the above. What have you tried so far?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

905 views 3 9
Read article

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