In a database I am working on, I have a form that does some validation of user-entered data before saving the document. If the original data entry is clean, and the form passes the validation, the document saves and closes as expected. If a user has entered some bad data, when the user goes back to the document from the validation messagebox and fixes the data, I get an error message stating “NotesUIDocument: Save Cancelled”. When I try to exit out of the document, it will ask me if I want to save my changes; I say yes, but it still does not close the document. I must close the document by saying no to the prompt.
The validation is done via LotusScript.
Subject: error when saving in the UI
Put the validation code in a function and return some value.based on the function return value, save the document.
Somethink like this…
Sub Querysave(Source As Notesuidocument, Continue As Variant)
If Not ValidateSubmit Then
continue=False
End If
End Sub
where validateSubmit is a function
Function ValidateSubmit As Boolean
'xxxx-Your validation code goes here…
’ if didn’t passes the validation then return false
End Function
Subject: error when saving in the UI
I get an error message stating “NotesUIDocument: Save Cancelled”.
If you save the document via a call to notesuidocument.save, and you have validation logic somewhere - such as in Querysave - that might cancel the save, you should put the call to .save in an error trap, like this:
on error resume next
call notesuidocument.save
on error goto 0
This just tells the form to ignore any error that occurs on the call to save. With that call done, it resets error handling back to normal.
Put your validation in the Querysave, or in the various fields’ Input validation events.
There seems to be a disconnect between notesuidocument.save and the form. If the form’s save event is kicked off via Lotusscript, the form seems not to know whether it is dirty or not, and it will ask you if you want to save changes even if you have not made any since saving. This disconnect has always puzzled me. One thing you can do is put a global boolean variable on the form. Set this to True in the QuerySave; set it to False in the PostSave. If the save gets cancelled, the postsave event will not run. So, if you click on save and the variable is still false, you know the save was cancelled. This example closes the window without prompting after a successful save:
Button
on error resume next
call notesuidocument.save
on error goto 0
if not dirty then
call notesuidocument.close(true)
end if
QuerySave
dirty = true
PostSave
dirty = false
When I try to exit out of the document, it will ask me if I want to save my changes; I say yes, but it still does not close the document.
Check the queryclose event, something might be setting continue to False there.