Trying to save document using CommandService

Integration questions/issues
Post Reply
jonny_s
Posts: 5
Joined: Tue Sep 19, 2017 10:27 am

Trying to save document using CommandService

Post by jonny_s » Mon Sep 17, 2018 9:33 am

Having an issue using the CommandService when trying to save a document via a "Save and Close" link.

The document in question is open in my browser, in editing mode. I make some changes to the document (add bold text, change colour, etc) and then click on my "Save and Close" link. This link sends the following AJAX request to the document server:

Code: Select all

$.post(
	"https://document.server/coauthoring/CommandService.ashx",
	"{\"c\": \"forcesave\", \"key\": \"document_editing_key\"}"
);
The server accepts this request (with no errors), but sends me back the following JSON:

Code: Select all

{key: "document_editing_key", error: 4}
This means that the document server hasn't noticed the changes in my currently open document, and therefore isn't going to save them. However, I do have changes visible in my editor and the document title has an asterisk next to it, signifying there are unsaved changes. Why does the document server send me an error of 4, implying that the document hasn't changed, when the document has changed?

(I have double-checked the document editing key - the key that is sent and the key that is returned are exactly the same, so the server is trying to save the right document.)

Alexander_mb
Posts: 40
Joined: Tue Aug 08, 2017 2:01 pm

Re: Trying to save document using CommandService

Post by Alexander_mb » Tue Oct 02, 2018 6:55 am

Hello,

The asterix is shown when there are changes which were not saved on the server.

Please do the following to check if the changes were not saved:
1. Try to close the tab in browser, if there are any unsaved changes, you will see the following dialog window: "Changes you made may not be saved."
2. Enter the editing mode with a second (different) user and check if he sees the changes.

It might be that the strict mode of the co-editing is on and that is why the changes are not saved automatically.

jonny_s
Posts: 5
Joined: Tue Sep 19, 2017 10:27 am

Re: Trying to save document using CommandService

Post by jonny_s » Tue Oct 02, 2018 11:52 am

Hi Alexander,

Unfortunately, your response does not help with my issue. I'm not having an issue saving the document within the editor itself; the problem is when I'm trying to use the API.

Maxim
Posts: 1751
Joined: Tue Oct 11, 2016 2:34 pm

Re: Trying to save document using CommandService

Post by Maxim » Fri Oct 05, 2018 9:32 am

Hello jonny_s!
This means that the document server hasn't noticed the changes in my currently open document, and therefore isn't going to save them.
Yes, the changes you have made are not saved yet because there is "currently open document". These changes are saved in the Document Server's cache because the session i still open, but when you close the browser with the document after 5 seconds Document Server "understands" that this document must be collected and saved int the storage. Document Server collets file and send request with the link to the Document Manager to download this document. Do not forget that it needs 5 seconds for the Document Server.

jonny_s
Posts: 5
Joined: Tue Sep 19, 2017 10:27 am

Re: Trying to save document using CommandService

Post by jonny_s » Tue Oct 16, 2018 9:42 am

Hello again,

So if I have a document editor open, I cannot use the CommandService to save a document because the document server cannot send my storage server a file until all the editors are closed - is that correct?

Are you able to give an example of a use case for the 'forcesave' command? We're experimenting with implementing it so an example would be helpful.

Carl
Posts: 92
Joined: Thu Apr 12, 2018 10:00 am

Re: Trying to save document using CommandService

Post by Carl » Wed Oct 17, 2018 8:05 am

Hello,

You can find information about forcesave here.

Post Reply