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

Storing User Details

Hi All,

 

Requirement: On App start, i would want to store name of the user, email id of user, logged in date and time in the User List. Now, if the user details are already present in the user list i want to update that record with new logged in date and time. 
How can i achieve this in PowerApps?


Please help!!
Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
JR-BejeweledOne
Super User
Super User

Without knowing what your column types are you could do this.  Get the user details either using the User() function or the Office365Users.MyProfileV2 connector.   The connector you use is going to depend on how you are storing your information in the list.  

 

This information here is for Single line of text fields using the Full Name (provided by the User() function) of the user.

 

You can do something like this:  Replacing the data source name and column names with your data.  You will see a delegation warning on the CountRows with Filter, so if your list is going to grow very large, you could start this off by creating a temporary collection of user names that match the logged in user and then use that in the countrows function.    See second formula.

 

 

If(
    CountRows(Filter(DataSourceList, FullName = User().FullName)) >0,

    UpdateIf(DataSourceList, FullName = User().FullName, {Email: User().Email, LoggedInTime: Now()}),
    Patch(DataSourceList, Defaults(DataSourceList), { Title: "SomeTitleHere", FullName: User().FullName, Email: User().Email, LoggedInTime: Now()})

    )

 

 

 

ClearCollect(TempNames, Filter(DataSourceList, FullName = User().FullName))

If(
    CountRows(TempNames) >0,

    UpdateIf(PowerAppsMagicList2, FullName = User().FullName, {Email: User().Email, LoggedInTime: Now()}),
    Patch(PowerAppsMagicList2, Defaults(PowerAppsMagicList2), { Title: "Otterville", FullName: User().FullName, Email: User().Email, LoggedInTime: Now()})

    )

 

 

 

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

View solution in original post

1 REPLY 1
JR-BejeweledOne
Super User
Super User

Without knowing what your column types are you could do this.  Get the user details either using the User() function or the Office365Users.MyProfileV2 connector.   The connector you use is going to depend on how you are storing your information in the list.  

 

This information here is for Single line of text fields using the Full Name (provided by the User() function) of the user.

 

You can do something like this:  Replacing the data source name and column names with your data.  You will see a delegation warning on the CountRows with Filter, so if your list is going to grow very large, you could start this off by creating a temporary collection of user names that match the logged in user and then use that in the countrows function.    See second formula.

 

 

If(
    CountRows(Filter(DataSourceList, FullName = User().FullName)) >0,

    UpdateIf(DataSourceList, FullName = User().FullName, {Email: User().Email, LoggedInTime: Now()}),
    Patch(DataSourceList, Defaults(DataSourceList), { Title: "SomeTitleHere", FullName: User().FullName, Email: User().Email, LoggedInTime: Now()})

    )

 

 

 

ClearCollect(TempNames, Filter(DataSourceList, FullName = User().FullName))

If(
    CountRows(TempNames) >0,

    UpdateIf(PowerAppsMagicList2, FullName = User().FullName, {Email: User().Email, LoggedInTime: Now()}),
    Patch(PowerAppsMagicList2, Defaults(PowerAppsMagicList2), { Title: "Otterville", FullName: User().FullName, Email: User().Email, LoggedInTime: Now()})

    )

 

 

 

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,635)