cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AvenaFernando
Helper II
Helper II

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
v-yamao-msft
Community Support
Community Support

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.

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
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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (3,094)