Hello.
I have a button inside my app that I am using to send all the rows from a Collection to a Table located in a MySQL database. I am trying to implement a way to catch any errors that might happen in the process of sending the data (missing Internet connection, etc...) so that I can tell the user to try to send the data again.
Here is the code that I am currently using for that:
MySQLTable contains columns (ID, Field1, Field2)
MyCollection contains columns (tempID, tempField1, tempField2)
ForAll(MyCollection,
Patch('MySQLTable', Defaults('MySQLTable'),
{
ID: tempID,
Field1: tempField1,
Field2: tempField2
}
);
// Check if there were any errors when the data was submitted
If(!IsEmpty(Errors('MySQLTable')),
Collect(MyCollectionBackup, Filter(MyCollection, tempID = 'tempID'));
);
);
My idea is that at the end of each iteration of the For loop, a row from MyCollection will be sent to MySQLTable. If there were any errors trying to do that, then this row should be stored in MyCollectionBackup. At the end of the loop, MyCollectionBackup should contain all the rows that failed to be sent, so that the user can try to send them again later.
Can anybody please tell me if I'm doing this correctly, or if there is any better way to achieve this?
Thanks in advance.