Compare user value for 2 user picker fields

Is it possible to compare 2 user values for 2 different user picker custome fields and to block a transition based on this being true?

3 answers

1 accepted

1 vote
Accepted answer

cfValues['User picker field1'] != cfValues['User picker field2']

That worked thanks! Not sure why it was not working before when I tried it.

did you tried like this?

cfValues['User picker field1']?.name== cfValues['User picker field2]?.name

the following code we are using in our plugin, you have to conver it to groovy
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.crowd.embedded.api.User;
CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager();
CustomField cfField1 = cfm.getCustomFieldObjectByName("Field1");
CustomField cfField2 = cfm.getCustomFieldObjectByName("Field2");
User user1 = (User) issue.getCustomFieldValue(cfField1);
User user2 = (User)issue.getCustomFieldValue(cfField2);
if(user1 !== null && user2 !=null){
		s.o.p("both field values are equal")


is those custom fields are sing user picker or multiuser picker?

Yes but gives false result. also tried with *.value and only .value

All of these provide the same problem.

single user

i have update my answer check that, i think we have to use cfValues['User picker field1']?.name to get user name from user picker custom field

Not quite sure what you mean by convert it to Groovy

what i gave code is used on our java plugin but you are executing this on groovy script runner so that's why i said to convert to groovy!

i don't have much knowledge on groovy but i think it is almost same, you can try as it is on my answer!!

cfValues['User picker field1'] != cfValues['User picker field2']

should be sufficient. If that doesn't work they aren't equal, or they are different types. Use admin -> built-in scripts -> condition tester.

@Jamie Echlin [Adaptavist]

How can I compare Assignee with multi user picker field?

Hello Jamie,

Can I kow how can i compare None value/Option for the custom field of type select,

I want to restrict users from performing the transition unless the value of my custom field equals to None,

Can you please help..

Thanks and regards,

Moiz Shaikh.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

466 views 8 27
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