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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,044)