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?
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){ if((user1.getName()).equal(user2.getName())){ s.o.p("both field values are equal") } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is those custom fields are sing user picker or multiuser picker?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes but gives false result. also tried with *.value and only .value
All of these provide the same problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
single user
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not quite sure what you mean by convert it to Groovy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How can I compare Assignee with multi user picker field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.