Если я правильно понимаю, вы хотели бы сохранить то, что в данный момент находится в EditForm1, в локальную коллекцию, и после получения интернет-соединения вы хотели бы снова отправить форму.
Вы захотите использовать условие для сохранения данных, которые в данный момент находятся в форме, если вы подключены к Интернету, в противном случае соберите их во временную коллекцию.
If(ToggleIsConnected.Value,
//If you are connected to the internet, then write the data to the database.
SubmitForm(Form1),
//If you are NOT connected to the internet, then write the data to a temporary collection to be written later.
Collect(temporary,
{id: Max(temporary,id)+1,
column1: InputColumn1.Text,
column2: InputColumn2.Text
}
);
SaveData(temporary,"temporary")
)
Вы можете использовать Toggle для проверки интернет-соединения. В случае, если вы потеряли соединение, сохранили данные локально и восстановили соединение, тумблер включится и автоматически выполнит действия OnCheck:
If(!IsEmpty(temporary),
// If the connection returns and there are records to be written,
// then perform these actions:
ForAll(temporary,
// For each of the records in the temporary collection,
// save their data to a new row in the connected datasource.
// If writing was successful, copy it to a collection called 'success'
// to identify it.
Collect(success,
{id: id,
Record:
Patch(datasource,Defaults(datasource),
{column1: column1,
column2: column2
}
)
}
)
);
If(IsEmpty(Errors(datasource)),
// If there are no errors with the datasource,
// go ahead and clear the entire temporary collection since you're writing.
Clear(temporary),
// Otherwise if there is an error, remove only the records that were successful.
// Then clear the successful records.
// Keep records that had an error so they could be attempted later.
Remove(temporary,Filter(temporary,id exactin Filter(success,!IsBlank(Record)).id));
Clear(success)
)
)
Обратите внимание, что здесь я использую Patch (), чтобы сохранить то, что было во временной коллекции. Я не могу использовать SubmitForm, если не заполняю форму.
Есть еще несколько шагов для дальнейшей реализации. Пожалуйста, смотрите мое видео на эту тему для более подробной информации:
https://www.youtube.com/watch?v=j30xOM5OmRE