web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Finding out current logged in user's login id / email id and other information

(0) ShareShare
ReportReport
Posted on by

I am looking to find some information of the logged in user, like the login id/email id and some other stuff using XRM tools in JavaScript. 

I have tried the Xrm.Utility.getGlobalContext(), but the information provided in this object isn't sufficient for what I want to achieve.

To give some context, I m trying to fetch some information from my Azure AD using the currently logged in user's context.


Can someone please advice a way out?

I have the same question (0)
  • Verified answer
    LuHao Profile Picture
    40,892 on at

    Hi anktify,

    If 

    var context = Xrm.Utility.getGlobalContext();
    var userId = context.userSettings.userId;

    is invalid, try using Xrm.Page.context.getUserId().

    You could refer to this post and this article.

    Hope this helps.

    Best Regards,

    Lu Hao

  • Community Member Profile Picture
    on at

    Thanks Lu Hao! Will try this out!! :)

  • LuHao Profile Picture
    40,892 on at

    Hi anktify,

    Is this method useful? If you have any questions, please feel free to post.

    If my answer helped you solve this problem,please mark the reply as answer so that it can help others. :)

    Best Regards,

    Lu Hao

  • Community Member Profile Picture
    on at

    Hey,

    The "Xrm.Page.context.getUserId()." didn't yield the desired result and neither did the article.

    The post that you have given the link to seems interesting and I am yet to try that.

    Will get back to you on that!

    Regards,

    Sanchit

  • Suggested answer
    Emre GULCAN Profile Picture
    2,379 on at

    Hi,

    With new javascript API (called v9) you can get user settings with codes below, however returned data a bit different on legacy web UI and Unified Interface.

    var globalContext = Xrm.Utility.getGlobalContext();
    var settings = globalContext.userSettings;


    You can find details on https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/getglobalcontext and https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/getglobalcontext/usersettings 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans