cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Populating a user column with logged-in user (Dataverse for Teams)

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

6 REPLIES 6
Super User II
Super User II

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

Frequent Visitor

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 

Super User II
Super User II

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...

Frequent Visitor

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 


Super User II
Super User II

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. 

Frequent Visitor

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! 

 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Users online (3,633)