Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.