I’m trying to refresh a document by closing and reopening it, but somehow I am getting a save conflict and the parent is being saved with a field named SaveOptions set to zero. How can that possibly be? Here is my code:
My SaveOptions field is Computed text, formula: “1”
Call doc.ReplaceItemValue(“OpenTab”, dept)
Call doc.Save(True,True)
Call uidoc.FieldSetText(“SaveOptions”,“0”)
Call uidoc.Close()
Call ws.EditDocument(True, doc)
After this code is executed, I make changes in other fields, then click Save (or Save and Close) and I get the conflict warning: Another copy of this document was saved… blah blah blah.
The code is somehow saving the document with SaveOptions as zero. How do I avoid that?
Subject: RE: How is a doc saved with SaveOptions “0”?
Your problem is that when you close and reopen the document, you still have a handle to the document variable that has the SaveOptions field set. You have to be careful with things like that. To clean it out, try this:
Call doc.ReplaceItemValue(“OpenTab”, dept)
Call doc.Save(True,True)
'Get Universalid for the document
docunid = doc.UniversalID
Call uidoc.FieldSetText(“SaveOptions”,“0”)
Call uidoc.Close()
Set doc = Nothing
Set uidoc = Nothing
'Get a fresh handle to the document
Set doc = db.GetDocumentByUNID (docunid)
Call ws.EditDocument(True, doc)
Also, just to be on the safe side, add the following in your PostOpen event:
If doc.HasItem(“SaveOptions”) then call doc.RemoveItem(“SaveOptions”)
Subject: RE: How is a doc saved with SaveOptions “0”?
Hi,
If Stephen has solved your problem then it’s ok.
Otherwise put code like Call uidoc.FieldSetText(“SaveOptions”, 1), instead of Call uidoc.FieldSetText(“SaveOptions”,“0”) and check with Domino Designer Help for details.