Hello there!
We are currently in the process of migrating to Jira Cloud and reworking old DC scripts to work on Cloud.
One issue we have found is the inability to get a users email address programmatically via script console or listeners.
For example the following code snippet returns data about the reporter, but the email address attribute is null no matter if I run it as logged in user or scriptrunner add on user
def issue = Issues.getByKey('PG-547')
[issue.reporter]
// returns
[
{
"entityProperties": {
"keys": [
"ai-streaming-spotlight",
"attachment-spotlight-seen",
"card-cover-spotlight-seen",
"com.atlassian.jira.frontend.VisualRefreshIconCacheBuster:clear-cache-state-v2",
"help_button_ui_state",
"jira.home.last-visited-tab",
"jsw-onboarding-checklist.open",
"jsw-onboarding-checklist.open-task",
"jsw-onboarding-checklist.visibility",
"jwm.overviews.plan.import.state",
"navigation_next_ui_state",
"standard-roadmap.board-34",
"standard-roadmap-macro.board-34"
]
},
"accountId": "removed",
"accountType": "atlassian",
"active": true,
"applicationRoles": null,
"avatarUrls": {
"16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/D-2.png",
"24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/D-2.png",
"32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/D-2.png",
"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/D-2.png"
},
"displayName": "Dmytro",
"emailAddress": null,
"expand": null,
"groups": null,
"key": null,
"locale": null,
"name": null,
"self": "https://autodoc-eu.atlassian.net/rest/api/2/user?accountId=removed",
"timeZone": "Europe/Berlin"
}
After doing some investigation we found out that it could be because of the user profile settings email is set to the organization only instead of public (in case of public the email is found and works ok). But all our users are already managed in the organization by default and scriptrunner is also installed here so it should work even though users' email is not set to public
I have tried to add the scriptrunner app in the admin panel to have access to the organization data and from the described permissions it says on the last line that the app should indeed have access to user profile data including the email.
So the question is - is there some additional configuration that needs to be done or are we doing something wrong in order to get the user email from the reporter/assignee/user picker fields? Or is there some additional setting that can help bypass there gdpr restrictions ?
This functionality is critical for us because we have a lot of integrations using the emails? especially the issue.reporter.email syntax because as you can see it is not working currently
I have also found the dev /rest/api/3/user/email API that seems to work no matter the privacy settings set, so why does scriptrunner not have this built in?
The API scope and permissions seem to match those set in the scriptrunner app from the admin panel as far as I can tell
Do I have to use a helper function to get the emails instead from now on?
How do others deal with this use case?
Thanks!
HI @i_gavirlita ,
in addition to what @Kristian Walker _Adaptavist_ said, there is a workaround, that indeed doesn't always guarantee results, but is my usual go-to route:
Generally, I use the following endpoint to search for user accounts based on things I know, like the e-mail address, their name or their accountId:
https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-user-search/#api-rest-api-2-user-search-get
A simple get request to the following URL would be enough to get 1-n user object(s) returned for every user with "sendek" in their display name or email-address:
https://autodoc-eu.atlassian.net/rest/api/2/user/search?query=sendek
Since you are looking for a particular reporter in your example, you could also pull the accountId of the reporter and use the following URL instead:
https://autodoc-eu.atlassian.net/rest/api/2/user/search?accountId=$HERE_THE_ACCOUNT_ID_OF_THE_USER
Again, specifically in your case, the following REST endpoint could also be valuable: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-user-search/#api-rest-api-2-user-search-query-get
Using the following URL that includes a query to get the reporter of the work item with key SOLWORK-1, you would receive the user object:
https://autodoc-eu.atlassian.net/rest/api/2/user/search/query?query=is%20assignee%20of%20SOLWORK-1
That being said, it's possible that those endpoints are not available to Script Runner or the .get-method within Script Runner and you need to authorized yourself for them with your own credentials that you need to store in the script. But I hope, despite this fact, it's helpful for you to solve your challenge.
Greetings
Philipp
Hi @i_gavirlita ,
as this is a question related to Script Runner and you're paying for the license, the best way for me personally is always to create a support ticket. They are surely glad to help you.
You can create a support request with them here: https://the-adaptavist-group-support.atlassian.net/servicedesk/customer/user/login?destination=portals
To still give your question visibility, let me mention a few people from Adaptavist who will be able to point you in the right direction. :-)
FYI @Astrid Sieben @Phill Fox @Kristian Walker _Adaptavist_
Greetings
Philipp
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Philipp Sendek _catworkx_ ,
Unfortunately, in Jira Cloud, there is no guaranteed way to retrieve a user's email if they have chosen to hide it in their profile settings, as Atlassian does not expose it via the API due to GDPR regulations.
This means you can only get a user's account ID and display name, so if you need to do some logic to map account IDs to emails many times in your script, that is needed.
I understand this is frustrating, but please note this is not possible under Atlassian's GDPR policy.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kristian Walker _Adaptavist_ our users have the email visibility set at organization level, so its not hidden. Why I cant still retrieve it in this case?
Also, what is the point of the dev API to get emails if its not working in scriptrunner? It should be possible via it, no?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@i_gavirlita - Unfortunately, the emails are not provided in the rest API by Atlassian, and ScriptRunner uses this in the cloud, meaning ScriptRunner cannot work around this.
Regards,
Kristian
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.