Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert diplay name to username

Andrii Strelka March 13, 2018

Hello everyone. How to convert Display Name (for example Peter Levicki) to username in Groovy or simply assign by full name?

1 answer

1 vote
Alexey Matveev
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.
March 14, 2018

You can find a user by display name like this. The it varable contains the user.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.bc.user.search.UserSearchParams


def userSearchService = ComponentAccessor.getComponent(UserSearchService.class);
UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(true).includeInactive(false).maxResults(100000).build();

userSearchService.findUsers("matveev alexey", userSearchParams).each{ it->
log.error(it.getKey())
}
Andrii Strelka March 14, 2018

I know about this method , but I use Jira 6 ( This version not provide UserSearchService module

Alexey Matveev
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.
March 14, 2018

Then you need to iterate over all users and find the required user.

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.security.login.LoginManager def loginManager = ComponentAccessor.getComponent(LoginManager.class); ComponentAccessor.getUserManager().getAllUsers().each{ it->

if ("user display name".equals(it.getDisplayName()))

    log.error(it.getKey())

}

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events