Hi,
I need your help to solve an issue concerning if function.
I've created an app which allows an auditor to add compressed air leaks (location, description) of the factory to a collection being offline. Then, when he grab an internet connection, a button permit him to upload those leaks to an Excel database stored on the factory's buisiness drive. There are hundreds of records to upload so the process is quite long but it doesn't matter.
The problem is that if during the upload, the internet connection crashes, all the leaks not uploaded yet are lost !
To avoid this to happen I putted the remove function in an if(Connection.Connected, remove(collection, last record uploaded). But the condition is only checked once when the upload button is actionned so when connection cut off the collect function stops while the remove function keep running.
How, without using a timer, can I force the condition to be checked each time a leak is uploaded ?
Here's my upload button code :
If(Connection.Connected && CountRows(LeaksToBeAdded)>0;
ClearCollect(TemporaryCollection; LeaksToBeAdded);;
ForAll(TemporaryCollection; Collect(DB_LEAKS; First(LeaksToBeAdded));;
If(Connection.Connected; Remove(LeaksToBeAdded;;
First(LeaksToBeAdded)));;
SaveData(LeaksToBeAdded; "NewLeaksInLocalStorage"));;
Refresh(DB_LEAKS);;
ClearCollect(LeaksCollection; DB_LEAKS);;
SaveData(LeaksCollection; "LeaksInLocalStorage");;
Back();
Connection.Connected && CountRows(LeaksToBeAdded)=0;
Notify("No leaks to be added"; NotificationType.Error);;
Back();
Notify("You are offline, find internet connection to proceed";
NotificationType.Error))LeaksToBeAdded corresponds to the collection which store the leaks recorded when offline.
DB_LEAKS is the database storing all the leaks in compressed air network, filled by the app.
LeaksCollection is a collection used as a cache for DB_LEAKS database.
Attached a flowchart of the upload button OnSelect actions.