cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CoachOffice365
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

1 ACCEPTED SOLUTION

Accepted Solutions
EricRegnier
Super User
Super User

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. 

View solution in original post

6 REPLIES 6
EricRegnier
Super User
Super User

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

CoachOffice365
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 

EricRegnier
Super User
Super User

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

CoachOffice365
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 


EricRegnier
Super User
Super User

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. 

View solution in original post

CoachOffice365
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,103)