cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnderAltjoe
Helper I
Helper I

Updating already patched item in Sharepoint list

Hello,

 

Is it possible to update already patched item from sharepoint? For example lets say there is number 10 on the list, but user wants to change it to number 13, but does not want to create separate item but change the existing one, is it possible?

 

Thanks in advance,

Ander Altjoe

7 REPLIES 7
ASHetap
Resolver I
Resolver I

Yes this is possible,

 

The patch function is meant to add and update items in a list or datasource

 

from the documentation:

Patch( DataSource, BaseRecord, ChangeRecord )

 

so if you pass the existing record in "Base Record" you update it with the values of "ChangeRecord "

 

if you want to share some code im glad to help

 

hope it helps, if this answers your question please mark it as answered

anibra
Resolver II
Resolver II

Hi @AnderAltjoe ,

 

yes you can do it. But first you need to find the record you want to update. You can do it by using Lookup function and then use the Patch function. Here is an example which updates the quantity of the ice-cream with flavor chocolate: Patch( IceCream,
Lookup( IceCream, Flavor = "Chocolate" ), { Quantity: 400 } )

Thank you for quick reply.

Basically I have some items under each other and text inputs right next to them (added png to the attachment). Those items are actually buttons, but the border and fill is transparent. When user enters number to the text input then the button (items next to the text inputs) gets selected and patched automatically. My question is if the user wants to change the number in the text input, can the Power Apps update the patched item instead of making a new item?

 

My code right now is:

Patch('Collection 2'; Defaults('Collection 2');
{SharepointColumn: TextInput.Text}
)

ASHetap
Resolver I
Resolver I

If you pass  Defaults('Collection 2') to the patch function you say to create a new record in this collection,

 

what you want to do is pass the item you want to update instead of Defaults, so you want to first get the original record with a lookup or filter and do something like

 

Patch('Collection 2'; Lookup('Collection 2', SharepointColumn = 10),
{SharepointColumn: TextInput.Text}
)

 

 

anibra
Resolver II
Resolver II

You can check fist if the item exist in sharepoint list (with lookup), if exist then update the record if not add a new record

Pretty much there, but how can I do it with any number, not only number 10. Users can enter any number to the text input.

anibra
Resolver II
Resolver II

Patch('Collection 2'; Lookup('Collection 2', SharepointColumn = TextInput.Text),
{SharepointColumn: TextInput.Text}
)

 

Instead of checking for the fixed value (10), check for the text input value

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,280)