david
April 19, 2020, 12:58pm
1
Using the documentation at – User – I’ve been trying to get details of the currently logged in user - particularly the Atlassian Account ID.
The code below, cribbed from the link above…
AP.user.getUser(function (user) {
console.log(" 👋 user id", user.id); // fails
console.log(" 👋 user key", user.key); // fails
console.log(" 👋 user name", user.fullName); // fails
});
AP.user.getCurrentUser(function (user) {
console.log(
" 👋 The Atlassian Account ID is",
user.atlassianAccountId
); // fails
});
AP.user.getTimeZone(function (timezone) {
console.log(" 👋 timezone", timezone); // works
});
AP.user.getLocale(function (locale) {
console.log(" 👋 locale", locale); // works
});
…produces the following in the console:
There are no user details for the currently logged in user available.
Has this ever worked?
Is there another API to use?
boris
April 19, 2020, 1:23pm
2
Be careful with this one, it is most likely returning the default cloud timezone. Not your user’s timezone.
1 Like
david
April 19, 2020, 3:30pm
3
No worries - I was just checking if any of those API calls worked correctly
Hi @david ,
I ran a test and was able to see the atlassianAccountId
field returned in the AP.user.getCurrentUser()
method. I opened the chrome dev tools and entered AP.user.getCurrentUser((user) => {console.log('user:', user)})
, targeting a glance panel on a JSD issue.
A couple of questions:
Which type of iframe are you executing this request against?
Are you logged into JSD with an Atlassian account based account (I understand non Atlassian account based accounts can also see JSD issues).
Regards,
Dugald
1 Like
david
April 20, 2020, 9:33am
5
Hi @dmorrow , thanks for the reply.
I was using a serviceDeskPortalFooters
module (footer panel ) so that I could access it from a single place wherever the user is in JSD
I was logged in as a full Atlassian account user
If I wanted to get a user identifier for either an Atlassian account user or non-Atlassian account user, should that be possible in one call?
AP.request('/rest/api/2/myself')
.then(data => {
current_user = JSON.parse(data.body);
})
This works for me
1 Like
david
April 21, 2020, 1:06pm
7
Perfect. Thank you very much.
1 Like