What is the empty value for a USER PICKER field - my script seems always returning "true"


I'm trying to add a "copy value from field to field" post function to my workflow - And I need it to be executed when condition is "true".

Please let me explain the scenario:
I need to get my issue assigned to the Component Lead automatically when it is being created (This is very easy to fulfill). But, I also have to assign to other people as needed (on the create-issue screen). That's not possible to put select user in "Assignee" system field (because it will still be assigned to the Component Lead). So, I added a new USER PICKER field, then add a post function to copy the value from the user picker field to the "Assignee" field.

I've tried with a few scripts, but was not successful.

Here are my 2 groovy scripts I put in [Conditional execution]:

// 1 //


 return true

} else {

 return false



//or *****************************


// 2 //

if(issue.get("customfield_11200").getName() != ""){

 return true

} else {

 return false



The issue is this script seems always return "true" value - means if I select a user then it works - if I keep it empty, then it throw errors - so the empty value here is not correct! I've tried "", null, empty - All are not accepted-.

Could you please advise what is the empty value for a user picker field??

OR, when I used the first script, it always return "true" - Assign to a user I put in the USER PICKER field or "Unassigned" when keep the filed empty.  How can I resolve this issue?

Thank you in advance!!


Thanks & Regards,
Olivier Chen

2 answers

1 accepted

As Nic said, you can just use a simplified version, but your code is wrong, there is no issue.get. Unless you're thinking of another plugin. The following will work :

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject("customfield_11200")
if (issue.getCustomFieldValue(customField)) {

But if this is in a condition block it's still simpler:

cfValues["Name of CF"]

That should be all you need to test if there is a value set.


Thanks Nic and Jamie!

I tried the code and it works!



0 votes

When a custom field is empty, there's actually nothing in the database for it.  So all your "get" functions sort of fail.

But it does make your code more simple.  Try:

if (issue.get("customfield_11200")) { return true }

Which means "if there is a value, then do something"

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


189 views 0 4
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