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")
)
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)
)
)
1 回答
如果我理解正确,您希望将当前在EditForm1中的内容保存到本地集合中,并在再次接收Internet连接时,您想再次提交该表单 .
如果您已连接到互联网,则需要使用条件来保存当前在表单中的数据,否则将其收集到临时集合中 .
您可以使用切换来检查互联网连接 . 如果您丢失连接,本地保存数据并重新获得连接,切换将触发并自动执行OnCheck操作:
请注意,在这里,我使用Patch()来保存临时集合中的内容 . 除非我填写表单,否则我无法使用SubmitForm .
还有一些步骤需要进一步实施 . 有关更详细的详细信息,请参阅我关于此主题的视频:https://www.youtube.com/watch?v=j30xOM5OmRE