Prevent save conflicts over the Web
This code will provide you with way of preventing save conflicts on the Web.
View member feedback to this tip.
This code will provide you with way of preventing save conflicts on the Web. I am not sure if somebody already published a similar tip, but I was looking for ways of preventing save conflicts on the Web and didn't find much. This code is in Java, but you can do the same using LotusScript.
In the webQuerySave agent I have created a method to check for conflicts ($Conflict) field. public boolean isSaveConflict(Document doc) { boolean isSaveConflict; try { if (doc != null && doc.hasItem("$Conflict")) { isSaveConflict = true; } else { isSaveConflict = false; } return isSaveConflict; } catch (NotesException ne) { ne.printStackTrace(); return true; } } So if isSaveConflict method returns true I call another method processSaveConflict public void processSaveConflict(Document doc) throws Exception { // create new field called oldform where you store original form name for the reference doc.replaceItemValue("OldForm", doc.Form); // replace Form name to (for example) "SaveConflict" doc.replaceItemValue("Form", "SaveConflict"); // remove $Conflict field doc.removeItem("$Conflict"); // remove $REF (save conflict is a child doc to the original) doc.removeItem("$REF"); } // So if the save conflict is detected you can create an error page where you inform the user that the save conflict occurred and the document hasn't been saved, or you just print the message about save conflict. You can provide a go back button where you open original document. The agent can send an e-mail notification about save conflict. I also created a view where all save conflicts can be checked (the form name is SaveConflict).
The technique provided here will detect conflicts, but not prevent them. What will happen when conflict arises after this test condition is passed and while saving the document?
—Dhanasekar D.
*****************************************************************************
Well, you are right, it doesn't prevent the save conflicts. What it does is remove relation between original document and the save conflict (so you don't see it within the view) and notify user about it, so the user can try to save changes again. As far as I know, the only way to prevent save conflicts is to lock document, but this has its disadvantages too.
—Robert Ficek, tip author
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Robert Ficek. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.