
Announcements
I am trying to record the current user, how many times he/she used the app, and the last time he utilitzed the app.
My SPO List:
AppUser (Title:Text Person:PeoplePicker Usage:Int LastUsed:Date)
And I currently have it implemented like this:
Screen.OnVisible
Patch(AppUsers, Defaults(AppUsers), {Title:User().Email, LastUsed:Now(), Usage:0})
Button.OnSelect
UpdateIf(AppUsers, Title = User().Email, {Title:User().Email, LastUsed:Today(), Usage:Usage+1})
Two questions:
1. How can I use the User() to populate the "Person" field in the SharePoint List?
2. How can I combine both actions above into one?
ie( Check if User() is not in the list, add the user to list and set his usage to 1, else increment the usage by 1.
This syntax does not work:
Patch(AppUsers, Defaults(AppUsers), {Title:User().Email, LastUsed:Now(), Usage:Usage+1}
Thanks.
Tom
Hi tChmiel,
According to your description, I created a similar SharePoint list with you, say ListC.
Then created a connection from PowerApps to this list.
On the app, I configured the OnVisible property of the screen as:
If(User().FullName in ListC.Title,UpdateIf(ListC,Title=User().FullName,{LastTime:Now(),euru:euru+1}),Patch(ListC,Defaults(ListC),{Title:User().FullName,LastTime:Now(),euru:0}))
When I navigate to this screen, the item would be updated or a new item would be created.
PS: About Usage column, it was named as “Usage” in the list, but on the app, I was asked to use the name “euru”. So please make sure you were using the valid column name.
Hope my code could be a reference for you. And these documentations for your reference:
https://powerapps.microsoft.com/en-us/tutorials/function-if/
https://powerapps.microsoft.com/en-us/tutorials/control-screen/
Best regards,
Mabel Mao