Tip

Preventing save conflicts

I needed to update a parent document from a response document in a Web application, while the parent document was in edit mode. When the parent saved, I got a save conflict error. To solve my dilemma, I created the code below to set field values of the parent document. It uses the @SetDocField formula with the evaluate statement.

  
Dim doc as NotesDocument
Dim s as New NotesSession
Dim formula As String
Dim result as Variant
Dim fieldname as String
Dim fieldvalue as String


Set doc = session.DocumentContext 
 ---- Do all your calculation then update 
the fieldname with new fieldvalue.

formula = FormulaSetFieldValue(fieldname,
 fieldvalue) result = Evaluate
(Formula, doc)

Where = FormulaSetFieldValue is a tiny function:

Function FormulaSetFieldValue(fieldname 
As String, fieldvalue As String) As 
String
 FormulaSetFieldValue = {@SetDocField($Ref;} 
& {"} &  fieldname & {";} 
& fieldvalue & {)} End Function

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Viet Nguye. Please let others know how useful it is via the rating scale below. 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 October 2004

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.