cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AvenaFernando
Level: Powered On

Save only update rows on the table

I created the code below, so that when it is online, it performs the updateif using as id the product direct in the database online.

 

 

If(Connection.Connected;
	UpdateIf('01_Products_All';UNIQUE_ID_PRODUCTS=BrowseGallery2.Selected.UNIQUE_ID_PRODUCTS; { Brand  : DataCardValue1.Text; Quantity: Value(DataCardValue4.Text) } );
	
	ClearCollect(LocalProductsAllOffline;
		UpdateIf(LocalProductsAll;UNIQUE_ID_PRODUCTS=BrowseGallery2.Selected.UNIQUE_ID_PRODUCTS; { Brand  : DataCardValue1.Text; Quantity: Value(DataCardValue4.Text) } ));;	
	SaveData(LocalProductsAll; "LPA");;
	SaveData(LocalProductsAllOffline; "LocPAoff"))

When offline, it updates a collection (LocalProductsAll), which was created in OnStart with online data. But I wanted only the updated products to be written to LocalProductsAllOffline.

	ClearCollect(LocalProductsAllOffline;
		UpdateIf(LocalProductsAll;UNIQUE_ID_PRODUCTS=BrowseGallery2.Selected.UNIQUE_ID_PRODUCTS; { Brand  : DataCardValue1.Text; Quantity: Value(DataCardValue4.Text) } ));;	

Because when you go online again, it does not occur to execute the collection creation (LocalProductsAll), delete the updated values that were recorded.

 

The data that was updated would be saved in: LocalProductsAllOffline, to then send only the updated fields to sharepoint.

 

I need to write to the LocalProductsAllOffline table, only of the updated rows.

 

However, the code copies all lines from LocalProductsAll to LocalProductsAllOffline.

 

 

2 REPLIES 2
Community Support Team
Community Support Team

Re: Save only update rows on the table

Hi AvenaFernando,

 

Not sure with the two collections LocalProductsAll and LocalProductsAllOffline, what’s the data saved in these two collections?
Please try if you could use a filter function to filter only the updated rows and update them to SharePoint list.

 

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.
Highlighted
AvenaFernando
Level: Powered On

Re: Save only update rows on the table

Hi @@v-yamao-msf

 Not sure with the two collections LocalProductsAll and LocalProductsAllOffline, what’s the data saved in these two collections?

 

1. A collection to hold the online data, -> LocalProductsAll
2. A collection for the updated items, -> LocalProductsAllOffline

 

Understood?

 

In OnStart I create LocalProductsAll with columns structure and data online, and LocalProductsAllOffline I create only with the structure of the columns.

 

I have an UpdateIf in LocalProductsAll because it is this table when offline used in FormViewer or BrowseGallery1, so when updating offline, I have to show this data in some places (ex: BrowseGallery1).

 

 

ClearCollect(LocalProductsAllOffline;	UpdateIf(LocalProductsAll;UNIQUE_ID_PRODUCTS=BrowseGallery2.Selected.UNIQUE_ID_PRODUCTS; { Brand  : DataCardValue1.Text; Quantity: Value(DataCardValue4.Text) } ));;		SaveData(LocalProductsAll; "LPA");;

After updating with updateif, I thought this record would go to the LocalProductsAllOffline collection, but it copies the entire table.

 

 

If creating a filter for only the updated product for the LocalProductsAllOffline collection, would it be best?

 


 

Please try if you could use a filter function to filter only the updated rows and update them to SharePoint list.

 

 

For this, I thought the way would be to add an update_field column (AddColumns) in the LocalProductsAll table?

 

So when I perform updateif write true to update_field?

 

And so when this data is updateif when offline, when I go online do I send to sharepoint only columns with column update_field = true?

 

The idea of ​​creating a collection for:

A collection to hold the online date
A collection for the updated items

And had thought, informing about this with the post of Staff Carlos Figueira

Does the PowerApps solution have capability for offline working

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,681)