Can I check whether online documents are saved successfully through API

My business scenario is as follows:

  1. onlyoffice editor is embedded in web forms
  2. editor set autosave=true
  3. When the form is submitted, my own app server saves the form data along with the online document file

I did not find that onlyoffice has an api for synchronous saving, so:

  1. I temporarily save the form data
  2. wait for the online document api callback, and then save the form data with the document

My question is:

  1. Sometimes, due to network conditions, online documents are not automatically saved successfully. Can I check whether online documents are saved successfully through API? If the save is not complete, I want to disable the form submission
  2. Is there a more rigorous or simple process to handle my business scenario?

Hello @CarlWang

editor set autosave=true

Do you mean autoAssembly parameter? Configuring ONLYOFFICE Docs Developer Edition - ONLYOFFICE

As for the described scenario in general, as an independent integrator you can check Callback handler statuses for saving scenarios: ONLYOFFICE Api Documentation - Callback handler
If I misunderstood your scenario, please clarify it.

thanks Alexandre,
I know editor autoAssembly parameter and callback handler. I may not have described my needs clearly:

I have a form like this:
onlyoffice

when I click save button, I did the following:
1, call my application’s save document interface, which does the following:

  • create a document save record, set the status field =0
  • send forcesave command ,like:ONLYOFFICE Api Documentation - Command service
  • wait for the status field to change to 1
  • returns save success when status field = 1
    2, when I receive document server callback, I get document content and save to file,Then set the corresponding document save Record Status field to 1。The first step and the second step are equivalent to saving the document synchronously
    3, When the save document interface returns save success, submit form, then do subsequent processing based on the content of the form and the documents edited online.
  1. close form

My question:

When I perform the first step, the Document Editor must synchronize the content of the document being edited to the document server.Because of unstable network conditions, which can lead to websocket disconnection, sometimes onlyoffice editor will not auto synchronize the content being edited to the document server, I can determine through the API onlyoffice editor has been synchronized to the document server?If I can,then I’ll do the first step.

Hello @CarlWang
Thank you, it’s clearer now.

Because of unstable network conditions, which can lead to websocket disconnection, sometimes onlyoffice editor will not auto synchronize the content being edited to the document server

As far as I can see, a user should face reconnection scenario in such cases. The general information about these scenarios was described here: Errors when co-editing online (via Nextcloud): Cannot open files / Internet connection restored - #4 by Alexandre
The possible workaround solution seems to be similar as the one described there. Probably, if you catch the error event, it likely means that a user was disconnected and there might be an issue with unsaved changes: ONLYOFFICE Api Documentation - Config

Thank you very much, Alexandre!

document events feels like it should solve my problem.

1 Like