Hi,
I tried to get user name from email using ScriptRunner for Confluence. I tried the following code in scriptrunner console,
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.user.UserAccessor
def userAccessor = ComponentLocator.getComponent(UserAccessor)
def users = userAccessor.getUsersByEmail("ramakrishnan.srinivasan@xyz.com")
users seems to be a class com.atlassian.crowd.embedded.atlassianuser.CrowdSearchResult
But I am not able to figure out how to parse this result to get the user name?
Can you please help me?
Thank you
With warm regards
ramki
Hi Ramki,
You can do something like this:
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.user.UserAccessor
def userAccessor = ComponentLocator.getComponent(UserAccessor)
def users = userAccessor.getUsersByEmail("ramakrishnan.srinivasan@xyz.com")
if (users.pager().currentPage.size() == 1) {
return users.pager().currentPage.get(0).name
} else {
return "No single match"
}
Regards
Lasse Langhorn
Hi Lasse Langhorn,
Thank you, it worked for me.
regards
ramki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Should this work with JIRA?
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.