Forum Discussion
How to find UserName in a custom visual
Thanks for your reply Sam!!
No, I'm not looking for the USERNAME() DAX function. I'm actually looking for a simple way to get the username from my custom visual's JavaScript code.
When I view the page source of the PowerBI webpage, I see the below global JavaScript object taht actually has the username.
But I'm not 100% sure if I can rely on that object, so that it might not change in future breaking my code.
var powerbi = {
session : {
userInfo: {
name: '[email protected]',
givenName: xxxxx,
surname: xxxxx,
puid: xxxxx,
uoid: xxxxx,
alternateEmail: ''
}
}
};
- v-chuncz-msft10 years agoCommunity Support
Hi skakara,
Currently, playing with powerbi.session.userInfo in custom visual may not be reliable. See https://github.com/Microsoft/PowerBI-visuals/issues/412.
- nivasnalla8 years agoFrequent VisitorDo we have any update on this?
- v-viig8 years agoCommunity Champion
Power BI Custom Visuals API does not provide user name or user email.
We recommend to use DAX function to get user's email.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals