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.
Solved! Go to Solution.
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()})
)
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()})
)
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
208 | |
70 | |
49 | |
48 | |
20 |
User | Count |
---|---|
255 | |
125 | |
84 | |
77 | |
72 |