Hi.
I am developing a Power Apps app in Teams, and have it using a Dataverse table (Dataverse for Teams).
I need to get the value of the logged-in user to be the default value of a column "User" that is a lockup to the table "Users".
I try the solution as in https://powerusers.microsoft.com/t5/Microsoft-Dataverse/How-to-set-current-logged-user-as-default-va... with having the following formula:
DefaultSelectedItems =
If(
Form1.Mode=FormMode.New,
{
DisplayName: User().FullName,
Claims: "i:0#.f|membership|" & Lower(User().Email)
},
Parent.Default
)
It actually doesn't give any error, but at the same it doesn't show the logged in user neither.
Does anyone have an idea of what could be going on? Is it because I use Dataverse for Teams that the solution (that I believe is for Dataverse proper) doesn't work.
Grateful for any guidance.
I should add that I have other, strange things not working in my tenant (like getting a view on the Dataverse table to work for a Gallery view on the app) which might be related to this issue (if there's something fishy on the account/tenant level).
Thanks Magnus
Hi @CoachOffice365,
From what I know User() should work in Teams. User() is actually independent of Dataverse and is a built function of canvas apps. Are you trying to update a Dataverse record and set the column to the current user? Or you're just trying to filter a gallery?
Cheers
Hallo Eric and thanks for your reply. Yes, indeed, I have a form that when submitted creates a new record in Dataverse. The User() formula works for me as e.g. Text = User().Email for a label, but not in the combo box that is the user column (lookup to the User table in my Team's Dataverse).
I have the same app with SharePoint data storage, and then this post helped my get it working: Solved: Re: Auto populate person type column with logged i... - Power Platform Community (microsoft.... But for Dataverse the formula doesn't work, so that's why I am looking for that formula.
Cheers, Magnus
Thanks for the additional info. Are you trying to update an out-of-the-box column like Owner or it's a custom lookup column to User? Also, what's the error message?
Here's an example of how to update:
Patch(MyTable, Gallery1.Selected, { Owner: ComboBox1.Selected })
//Owner is the out-of-the-box Owner field
More info: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-references
Hope this helps...
Hallo Eric. Yes, it is a custom column with lookup to User. There's no error message, in fact; it just does not populate with the logged-in user. And I would like to avoid patching and just use a New Form and have all the data saved with SubmitForm. The linked page is interesting, but it is all related to the Owner column, right? Thanks
The link is related to Owner and other regular lookups.
The issue is when updating a lookup the GUID is saved in the database, you can’t save it with the user email or name that you get from User(). You’ll need to retrieve the User (systemuser) record based on User(), save it to another field or variable, then reference that GUID in your form/datacard.
Ok thanks Eric. Then I understand. I hope Microsoft will make it easier to work with this type of data in Dataverse for Teams as I think it will be a quite common requirement. Cheers!
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.