Save Conflict with backend-created document

I’m creating a new document on the backend with LotusScript and filling in some of the fields with the values of a currently open document.

Then I’m opening the newly-created document into the workspace for editing. So far this works fine, but when I try to save the newly-created and edited document, I get a message that the document was saved while I had it open and offers to create a Save Conflict document.

I tried closing the backend document before opening it into the workspace, but got an Illegal Use of Property error message.

How can I close the backend document before opening it into the workspace so I won’t get the error message?

Here’s my code:

Dim session As New NotesSession

Set db = session.CurrentDatabase

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim uiIssNum As Variant

    Dim uiCust As Variant

Set uidoc = workspace.CurrentDocument

uiIssNum = uidoc.FieldGetText ( "IssNum" )

uiCust = uidoc.FieldGetText ( "Cust" )



(many other fields copied)



Set doc = db.CreateDocument

doc.Form = "iss"

doc.SummDesc = "Evolved Issue"

doc.Evolved = "Yes"

doc.EvlvdNum = uiIssNum

doc.Cust = uiCust

 

    (Many other fields set in the backend doc)



unid$ = doc.UniversalID

Call doc.Save( True, True )

Set editdoc=db.getdocumentbyunid(unid$)

Set uidoc = workspace.EditDocument (True, editdoc)

Subject: Save Conflict with backend-created document

At the end of your script delete the next to last line (Set editdoc=db.getdocumentbyunid(unid$)), and in the last line change editdoc to doc. Since you already have a handle to doc it is not necessary to call getdoc… which results in your script having two references to the same document.

Subject: RE: Save Conflict with backend-created document

Thanks for your response!

Here’s the last part of the code as I understood you suggested it:

Call doc.Save( True, True )

Set uidoc = workspace.EditDocument (True, doc)

Trouble is, I still get the save conflict message when I try to close the document from the workspace. I even tried taking out the Save, but when I do save it from the open document, I get the save conflict message. Is there something I’m missing here?

Subject: RE: Save Conflict with backend-created document

I copied you code into a test agent and made the referenced changes (and a couple of field names to match the form I used) and the code executed perfectly with no save conflict. Are you getting the conflict on the new document or the original? You might try closing the original uidoc before opening the new doc for editing, or use a different handle to see if that helps. Here’s what I used: Dim session As New NotesSession

Set db = session.CurrentDatabase

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim uiIssNum As Variant

Dim uiCust As Variant

Set uidoc = workspace.CurrentDocument

uiIssNum = uidoc.FieldGetText ( "Category" )

uiCust = uidoc.FieldGetText ( "Subject" )

'(many other fields copied)

Set doc = db.CreateDocument

doc.Form = "Documentation"

doc.SummDesc = "TEST"

doc.Evolved = "TEST1"

doc.Category = uiIssNum

doc.Subject = uiCust

'(Many other fields set in the backend doc)

’ unid$ = doc.UniversalID

Call doc.Save( True, True )

’ Set editdoc=db.getdocumentbyunid(unid$)

Set uidoc = workspace.EditDocument (True, doc)

Subject: RE: Save Conflict with backend-created document

Thanks again for your help, Stan.

The conflict appears to happen with the new document. I’ve tried closing the original document before editing the new one, and changing the handle for the new one to uidocnew, but the result is the same. It’s odd, but I don’t get the offer to create a save conflict doc if I save the doc while it’s open, only when I attempt to close the new doc, even if it doesn’t ask me to save it.