Assuming you are writing a DocumentOperation, I think the nicest way is to throw a DocumentOperationException as soon as you decide not to save the document. Pass a message into the exception explaining why and that will be displayed to the user.
Save some documents but not others
I wrote some code to create a certain document. If the document passes a certain criteria, I want to be able to save that document. If it doesn't, I don't want it to save the document.
Is there a way to do this?
Please sign in to leave a comment.
That also assumes you are only doing one document. If you have many, then don't add the documents you don't want to save to the list of results that are returned.
^ True. Thanks.
I guess my main issue is with saveDocument(). I tried to call it but it won't save the document in question to the folder. So I am not sure if I am using the method correctly.
If you have just created a new document then you shouldn't call saveDocument(). That is only used if you are modifying a document that is already in the database.
To save a new document to the database then you can call DocumentUtilities.addGeneratedDocument
Sorry, I want to save an intermediate document to the database. I will try to call DocumentUtilities.addGeneratedDocument. Thanks!
Update: This solved my needs! Thanks!