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

store user() to SharePoint list person column

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

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

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

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yamao-msft
Community Support
Community Support

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

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,114)