how to compare User Picker (multiple users) field with a constant user name in groovy script

Manjunatha K R January 23, 2017

Hi,

I have a custom field "Release Prime" of type User Picker (multiple users).

I want to compare the "Release Prime" value is Server-release or Client-release or not using groovy script and do some action based on this validation in my Custom script validator- please advice how to do this.

 

UsernameFull NameLogin DetailsGroupsDirectoryOperations
Server-release
release@kodiakptt.com
Not recordedJIRA Internal Directory
  • Manju

 

1 answer

1 accepted

2 votes
Answer accepted
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2017

Here you are:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager

ArrayList<ApplicationUser> users = (ArrayList<ApplicationUser>) issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Соисполнители"))

UserManager userManager = ComponentAccessor.getUserManager();

return (users.contains(userManager.getUserByName("Server-release")) 
        || (users.contains(userManager.getUserByName("Client-release"))  ))
Manjunatha K R January 23, 2017

Thank you very much Vasiliy Zverev, it really works for me now.

Suggest an answer

Log in or Sign up to answer