Over the past week or so I have been seeing some very strange behavior in a few of my apps with regards to setting some variables and with the Office365Users connector. It's very bizarre and I can't figure out what is going on.
I have a variable, varUser, that is set on App start to Office365Users.MyProfileV2().DisplayName. This isn't a new addition, it's been there since the app was created and has been working fine. Once it's set it's used as a comparison to set another value.
It has stopped working properly even though nothing has changed. It appears to work on AppStart but if I set a label to varUser it's blank. If I hover it, it tells me that the variable is blank. If I use a button to set it to Office365Users.MyProfileV2().DisplayName, you can see that it does briefly as the name it sets it to flashes in the label and then goes away. Setting a different variable works fine, so I suspect it may have gotten corrupted. Not sure why or how though.
The other strange issue is trying to get any value from Office365Users.UserProfileV2(). When I enter an email address into it, it tells me that it's an invalid use of '.'
Why not just use the DisplayName property on User()? it should be the same thing as the one in the Profile and doesn't require a connector.
Because it's not always the same. This is per Microsoft
The information returned is for the current Power Apps user. It will match the "Account" information that is displayed in the Power Apps players and studio, which can be found outside of any authored apps. This may not match the current user's information in Office 365 or other services.
There are places in the app where we need to get the information about another user and you can't do that with the User() function.
You would think it was a Monday here. That did resolve that issue. Thank you. Now to figure out the other issue. As I said I think the variable is corrupted, it's the only thing I can think of.
I think that would only be for external users, if you shared with them. Otherwise it has always shown me what is in Azure AD for internal users, which is always the same as the Profile as far as I know. The problem is that the profile won't work for external users either, because external users by definition don't have profiles. Is the comment from Microsoft in the documentation or did someone tell you that? Would love to see a reference if you have it.
It's in the very first note of MS documentation for the function. We won't have external users using this app, so that's not a concern. You might also note the information about User().email. It doesn't return what you may think it does.
Rereading that quote the only way I can see it having something different than the O365 information is if the user has purchased a license based on a Microsoft Account. Otherwise they are logged in to the player or studio using their O365 account. Also, I was aware that Email was the UPN, which usually but not always matches the SMTP email. But normally its the UPN you need. I would still recommend using the User().DisplayName rather than making a call to the Profile. As I said, in the instances where the Display Name would be different the user's won't have a profile anyway. But in most cases it should be the same.
So the other reason to not use the User() function is because in our environment full name is FirstName, LastName and displayName is LastName, FirstName, so the User() function won't match what is in a person column in SharePoint.
Check out the News & Announcements to learn more.
Check out the new Power Platform Community Connections gallery!
Congratulations, the new Super User Season 2 for 2021 has started!
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.