cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Patch Function to Edit an Existing Record on Sharepoint List

So i am building an app to handle borrowing and returning shared laptops at the company. I created a Sharepoint list with the following columns and data types:

Name = Choice
Laptop = Choice
CheckedoutDate = Date and Time
CheckedinDate = Date and Time
Comments = Multiple Lines of Text

I have two screens, the checkout screen and the check-in screen. On the checkout screen users fill a form to submit the [Name, Laptop and the CheckoutDate is automatically retrieved and hidden] and a new row is created on the list using Submit(Form1).


Checkout.PNGCheckout Screen

 While on the check-in screen i have a form with the [Name, Laptop, Comments and the CheckinDate is automatically retrieved and hidden].

Checkin.PNG

What i am trying to achieve is that when someone selects a name and a laptop from the list and writes a comment, the last entry on the sharepoint list with that same name and laptop gets updated with the CheckinDate and comments.

I think i should use the Patch function to achieve that but unfortunately i wasn't able to write the correct function for that. Would someone please help?

Thanks a lot.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Patch Function to Edit an Existing Record on Sharepoint List

Hi @Anonymous,

Based on the formula that you mentioned, I think there is something wrong with it.

I have made a test on my side, please take a try to modify your formula as below:

 

Patch(
Laptops,
First(Filter(Laptops, Name.Value = DataCardValue8.Selected.Value && Laptop.Value = DataCardValue9.Selected.Value && IsBlank(CheckedinDate))),
{
CheckedinDate: Now()
}
)

Or

Patch(
Laptops,
LookUp(Laptops, Name.Value = DataCardValue8.Selected.Value && Laptop.Value = DataCardValue9.Selected.Value && IsBlank(CheckedinDate)),
{
CheckedinDate: Now()
}
)

More details about Patch function in PowerApps, please check the following article:

Patch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Anonymous
Not applicable

Re: Patch Function to Edit an Existing Record on Sharepoint List

Here is the code i am using to achieve that but it is not working:

Patch( Laptops, First( Filter( Laptops, Name = DataCardValue8.SelectedItems && Laptop =DataCardValue9.SelectedItems && IsBlank(CheckedinDate)=true )), { CheckedinDate: Now() } );

Anonymous
Not applicable

Re: Patch Function to Edit an Existing Record on Sharepoint List

Here are the controllers that i have in the checkin screen along with the error.

checkin screen controllers.PNG


 error.PNG

 

Community Support Team
Community Support Team

Re: Patch Function to Edit an Existing Record on Sharepoint List

Hi @Anonymous,

Based on the formula that you mentioned, I think there is something wrong with it.

I have made a test on my side, please take a try to modify your formula as below:

 

Patch(
Laptops,
First(Filter(Laptops, Name.Value = DataCardValue8.Selected.Value && Laptop.Value = DataCardValue9.Selected.Value && IsBlank(CheckedinDate))),
{
CheckedinDate: Now()
}
)

Or

Patch(
Laptops,
LookUp(Laptops, Name.Value = DataCardValue8.Selected.Value && Laptop.Value = DataCardValue9.Selected.Value && IsBlank(CheckedinDate)),
{
CheckedinDate: Now()
}
)

More details about Patch function in PowerApps, please check the following article:

Patch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: Patch Function to Edit an Existing Record on Sharepoint List

Thanks a lot for your help @v-xida-msft. It works perfectly as expected now. There is just one problem that although the Now() function retrieves the correct current date and time but submitting the form shows a different time on the Sharepoint list. It seems as if the time zone is changed upon submission to the Sharepoint list.

Capture.PNGPowerApps Time


 Capture1.PNGSharepoint List Time

 Any idea on how to fix that?

Thanks again.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 272 members 5,251 guests
Please welcome our newest community members: