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

How to submit data from offline collection/table to online.

Viewing the example - https://powerapps.microsoft.com/en-us/tutorials/offline-apps/ - in step 8:

 

 

If(Connection.Connected,
    ForAll(LocalTweetsToPost, Twitter.Tweet("", {tweetText: tweetText}));
    Clear(LocalTweetsToPost);
    Collect(LocalTweetsToPost, {tweetText: NewTweetTextInput.Text});
    SaveData(LocalTweetsToPost, "LocalTweetsToPost");
    UpdateContext({statusText: "Online data"}))

 

In this example, I understood that:

 

ForAll (LocalTweetsToPost, Twitter.Tweet ("", {tweetText: tweetText}));

 

For each record (tweetText) of the column (tweetText) of the collection (LocalTweetsToPost), passed to the function (Twitter.Tweet) to send the data to online mode.

 

But in my application, I use a list in sharepoint.

So I have the offline table (LocalProductsAllOffline) with several fields.

UNIQUE_ID_PRODUCTS | UNIQUE_ID_Description | Brand | Quantity | Quantity_Sold

And I need to update the online table (Products_All) 

 

I thought possible this code can accomplish this, tried to execute, but list sharepoint was not updated.

ForAll (LocalProductsAllOffline;
UpdateIf (Products_All; UNIQUE_ID_PRODUCTS = UNIQUE_ID_PRODUCTS; {Brand: Brand; Quantity; Quantity; Quantity_Sold: Quantity_Sold}))


Has anyone done this? how to make?

 

With function patch is possible? - https://powerapps.microsoft.com/en-us/tutorials/function-patch/

1 ACCEPTED SOLUTION

Accepted Solutions
AvenaFernando
Level: Powered On

Re: How to submit data from offline collection/table to online.

I already understood and I am using a collection for each situation.

 

1. A collection to hold the online data, -> LocalProductsAll
2. A collection for the newly added items, -> I do not use
3. A collection for the updated items, -> LocalProductsAllOffline
4. A collection for the deleted items, -> I do not use

 

And with the LocalProductsAllOffline collection, picking up each row in the table and sending it to online (01_Products_All).

 

I was able to do what I wanted with the following code. I used ForAll and the same UpdateIf and reporting tables[@columns]

 

If(Connection.Connected;
	ForAll(LocalProductsAllOffline;UpdateIf('01_Products_All';'01_Products_All'[@UNIQUE_ID_PRODUCTS]=LocalProductsAllOffline[@UNIQUE_ID_PRODUCTS]; 
		{ UNIQUE_ID_PRODUCTS : LocalProductsAllOffline[@UNIQUE_ID_PRODUCTS] ;
		 UNIQUE_ID_Description : LocalProductsAllOffline[@UNIQUE_ID_Description] ; 
		 Brand : LocalProductsAllOffline[@Brand] ;
		 Quantity: LocalProductsAllOffline[@Quantity] ;
		 Quantity_Sold: LocalProductsAllOffline[@Quantity_Sold] } )
	);;

	ClearCollect(LocalProductsAll;DropColumns('01_Products_All';"{Identifier}";"{Link}";"{Name}";"{Path}";"Author";"Created";"Editor";"ID";"Modified";"Title"));;
	SaveData(LocalProductsAll; "LPA");
	UpdateContext({statusText: "Local data"})
)

 

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: How to submit data from offline collection/table to online.

Hi @AvenaFernando,

 

Creating offline Apps for SharePoint list is not similar as the example article. There are many other aspects that we need to take into consideration.

 

Please take a look at the posts from Staff CarlosFigueira in the following thread:

Does the PowerApps solution has capaility for offline working

 

To build an offline App that would work for SharePoint list, we need to at least create 4 collections to work with it.

1.  A collection to hold the online data,

2. A collection for the newly added items,

3. A collection for the updated items,

4. A collection for the deleted items,

Depends on the connection status, we need to either update the data source directly, or update the local collection (then "sync" it with the Datasource when status is online).

 

Regards,

Mona

 

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AvenaFernando
Level: Powered On

Re: How to submit data from offline collection/table to online.

I already understood and I am using a collection for each situation.

 

1. A collection to hold the online data, -> LocalProductsAll
2. A collection for the newly added items, -> I do not use
3. A collection for the updated items, -> LocalProductsAllOffline
4. A collection for the deleted items, -> I do not use

 

And with the LocalProductsAllOffline collection, picking up each row in the table and sending it to online (01_Products_All).

 

I was able to do what I wanted with the following code. I used ForAll and the same UpdateIf and reporting tables[@columns]

 

If(Connection.Connected;
	ForAll(LocalProductsAllOffline;UpdateIf('01_Products_All';'01_Products_All'[@UNIQUE_ID_PRODUCTS]=LocalProductsAllOffline[@UNIQUE_ID_PRODUCTS]; 
		{ UNIQUE_ID_PRODUCTS : LocalProductsAllOffline[@UNIQUE_ID_PRODUCTS] ;
		 UNIQUE_ID_Description : LocalProductsAllOffline[@UNIQUE_ID_Description] ; 
		 Brand : LocalProductsAllOffline[@Brand] ;
		 Quantity: LocalProductsAllOffline[@Quantity] ;
		 Quantity_Sold: LocalProductsAllOffline[@Quantity_Sold] } )
	);;

	ClearCollect(LocalProductsAll;DropColumns('01_Products_All';"{Identifier}";"{Link}";"{Name}";"{Path}";"Author";"Created";"Editor";"ID";"Modified";"Title"));;
	SaveData(LocalProductsAll; "LPA");
	UpdateContext({statusText: "Local data"})
)

 

View solution in original post

Haladec
Level: Powered On

Re: How to submit data from offline collection/table to online.

Hi Fernando,

 

     I actually created an app which store some information about employees of the company. On the first screen appear general information about the employees. How can i make it able to display that first screen even when offline at the opening of the app. Considering we only have three column for the table which is name, Phone number and Job title.  Your help will be appreciated. 

 

   Thank you,

rohithmishra
Level: Powered On

Re: How to submit data from offline collection/table to online.

Do you also have an idea for below scenario:

1. Get data from datasource (Inspection, InspectionDetails) and store locally, say, LocalInspectionCollection and LocalInspectionDetailsCollection

 

In online - this works fine.

In order to insert records, we create a record using patch inInspection datasource, get the latest auto generated id and use this for the record insertion in InspectionDetails

 

Q1: How to make it work offline keeping the relationship intact  between Inspection and InspectionDetails tables?

Q2: How to show/refresh the gallery which has items of LocalInspectionCollection with the added record in offline [assuming user is working in offline mode]

Anonymous
Not applicable

Re: How to submit data from offline collection/table to online.

Hi ,I need bit of help regarding offline mode using sharepoint , I have tried everything but the local cached data is not getting updated in sharepoint when the app is getting reconnected to internet , though it doesn't shows any errors. Offline data not getting updated in sharepoint. Below is my code,

Pointer : When user is offline and trying to make a new entry his record is being saved in Collection "LocalUpdatedRecords" and when he regains the internet connectivity the records should be updated in sharepoint list "Offline test" .I have tried Using Patch ,Update ,Collect etc but nothing seems to update the records in sharepoint, any suggestions will be highly appreciated.

Thanks in advance.

 

If(Connection.Connected && CountRows(LocalUpdatedRecords)>0, ForAll(LocalUpdatedRecords,Patch(OfflineTest,Defaults(OfflineTest),{FirstName :lbl_FirstName,LastName:lbl_LastName,Age:lbl_Age,Mobile:lbl_Mobile})); Clear(LocalUpdatedRecords); SaveData(LocalUpdatedRecords,"LocalUpdatedRecordsToBeAdded"); Refresh(OfflineTest); ClearCollect(OfflineData2,OfflineTest); SaveData(OfflineData2,"LocalCachedData")); Navigate(BrowseScreen1,ScreenTransition.Cover)

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,350)