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?
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
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
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
Thanks Lu Hao! Will try this out!! :)
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