Fields appear twice or sometimes even three times in a document

Posted on 2007-10-10
Last Modified: 2013-12-18
Hi all,

I've just been asked to investigate a very interesting problem. There is this server (Domino 6.5.3 FP1), and there are two databases involved. A document is created in the first one (based on a modified mail template), manually, and then a new document is created in the second database.

Sub Postsave(Source As Notesuidocument)
      Dim cdb As notesDatabase
      Dim doc As notesDocument
      Set doc=source.document
      Set cdb=doc.ParentDatabase
      Dim BaseBT As notesDatabase
      Dim dp As NotesDocument
      Set dp=cdb.GetProfileDocument("CalendarProfile")
      Set baseBT=New notesDatabase(getRDVSrv(dp),getRDVDb(dp))
      Call doc.ReplaceItemValue("BaseOriginal",cdb.FilePath )      
      Call doc.ReplaceItemValue("ServerOriginal",cdb.server )      
      Call doc.ReplaceItemValue ("AuthorOriginal",cdb.parent.userName)
      Call doc.ReplaceItemValue ("Consultant",dp.getItemValue("user")(0))
      Dim docR As notesDocument
      Set docR=baseBT.CreateDocument ()
      Call doc.CopyAllItems (docR)
      Call docR.ReplaceItemValue("Form","RDVC")
      Call docR.ReplaceItemValue("DocOrigine",Source.Document.universalId)
      Call docR.Save(True,False)
      Call doc.ReplaceItemValue("DocOrigine",DocR.universalId)      
      Call CreerEntretien(doc)
      If (source.InPreviewPane) Then Exit Sub
      Call csEventObj.PostSave()      
End Sub

For some very odd reason, most fields appear twic in the second document, sometimes even more. Only Form and DocOrigin appear only once (!) in the document. The field $Revisions contains these dates: 01/10/2007 09:35:15 CET, 01/10/2007 09:35:17 CET, and 01/10/2007 09:35:41 CET.

The only thing that comes to my mind is that 6.5.3 FP1 contains a bug, in CopyAllItems, but there's no record of it anywhere.

Can you help me?? Is this a bug, does someone have an explanation, or how can I prevent it (document locking??)?

Additional info: Domino cluster, the document is created using the Notes client but there are multiple simultaneous web-agents running (2 at the moment).
Question by:Sjef Bosman
    LVL 46

    Author Comment

    by:Sjef Bosman
    Eh, in fact there are two sets of servers involved: database 1 on a cluster and database 2 on a different cluster. Wich may make things even more complicated...
    LVL 63

    Expert Comment

    Isn't it time to upgrade to at least R 6.55 or R 6.56 ( R 7.02 would be even better ).

    I know that this is not the kind of answer that you are looking for, but these kinds of problems are exactly the kind that get fixed with newer versions.

    Especially with clustering.

    I hope this helps !
    LVL 22

    Assisted Solution

    I always specify the optional second parameter when I use CopyAllItems.

    Call notesDocument.CopyAllItems( notesDocument [, replace ] )

    If you don't explicitly set the "replace" parameter to False, then duplicate items will be created for existing items with the same name.

    I wouldn't think that would be a problem for a new document, but it's the only thing I see in your code that is documented to create duplicate items.
    LVL 46

    Author Comment

    by:Sjef Bosman
    Thanks gentlemen! I'll look into both options tomorrrow, although I think that option 1 can be ruled out immediately (international bank, planned roll-outs, etc).

    LVL 31

    Accepted Solution

    As a test, try this bit of code:

    Msgbox join(doc.BaseOriginal,";"),,ubound(doc.BaseOriginal)
    Call doc.CopyAllItems (docR)
    Msgbox "copied to docR " & join(docR.BaseOriginal,";"),,ubound(docR.BaseOriginal)
          Call docR.ReplaceItemValue("Form","RDVC")
          Call docR.ReplaceItemValue("DocOrigine",Source.Document.universalId)
    Msgbox "saving docR " & join(docR.BaseOriginal,";"),,ubound(docR.BaseOriginal)
          Call docR.Save(True,False)
    Msgbox "done " & join(docR.BaseOriginal,";"),,ubound(docR.BaseOriginal)

    This way you can see when your code fires, and see the original value of one of the fields right before it gets copied, right after it get copied, right before the copy is saved, and right after. If you see it firing unexpectedly, you know that it is firing more than once... properly a nested event issue.  And you can compare the immediate results to what you ultimately find in the UI.
    LVL 46

    Author Comment

    by:Sjef Bosman
    Time to get back to you. I'm still not quite sure what caused this effect, but the problem seems to have subsided. Actually, I'm not quite sure it was even this piece of code. I noticed that the document was saved twice in the same agent, the calls were about 10 lines apart. The first save was required to obtain the document's UNID, in order to cross-reference the two documents. I moved some lines further down the code, and the problem has disappeared.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This is an old article, please see an updated version of this article, located here:
    Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now