cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jayant_2203
Helper II
Helper II

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.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (5,855)