Prevent save conflicts over the Web

Prevent save conflicts over 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

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

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).

MEMBER FEEDBACK TO THIS TIP

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.

This was first published in May 2005

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.