Hi There,I am trying to accomplish autosave of a document when it is open/edited on the web. I am familiar with the autosave feature you can check off in form properties but as I understand it this only applies to the notes client. Has anyone accomplished this on the web? if so how?
Subject: Possible solution for auto-save
Auto-save can be accomplished via a two step approach. However, a few things need to understand.
-
There is a NotesDocument and a NotesUIDocument… even on the web. In web development, I would call this the Document and the Form, but since this can confuse the issue (with Design Element types etc.) We’ll stick with NotesDocument and NotesUIDocument.
-
Using JavaScript and the Document Object Model, anything’s possible… you just have to account for everything once you get into the more advanced Domino Web Application development stuff.
-
You’ll need an understanding of the Domino CRUD API.
Once you’ve gotten that under your belt, we can discuss the two step approach.
-
Submit the contents of the NotesUIDocument.
-
Envelope the response into the NotesUIDocument.
This can all be done via AJAX to give us that automated user experience that most autosave engines provide.
Here’s the walkthrough:
On a timer, your AJAX function grabs the contents of the NotesUIDocument. It then checks the HTML Form Object’s “processing agent” - which is the value of the Attribute - to see if this is a new NotesDocument or an existing NotesDocument. If it’s “new” the action reads something like “Form?CreateDocument”. If it’s an existing NotesDocument, the action will read “View/NotesDocument?SaveDocument”.
Once you know what you’re doing, your AJAX function submits the request against the Domino CRUD API and waits for your result.
Your result… you’ll use a $$Return field that checks to see if this was a call placed via AJAX/autosave or via an HTML Form-based submission. If it’s an HTML Form-based submission, you’ll more than likely redirect back to a URL. If it’s your AJAX/autosave, you can respond with the return NotesDocument Universal ID.
Now, your AJAX function (we’ve hit step two) can use that returned NotesDocument Universal ID to update - via JavaScript and DOM - the HTML Form’s processing agent to go from “Form?CreateDocument” to “View/NotesDocument?SaveDocument”.
… and that’s pretty much it.
Does that 1) meet your functionality requirements and 2) make any sense?!
If you need a more detailed overview or an example, just let me know!
-Chris
Subject: autosave on the web
It’s possible but not straight forward. Using AJAX you can do this.