Documents copied using copytodatabase method reuse same unid

Source: Internet
Author: User
Problem

In Lotus Domino designer, when using the lotus script copytodatabase method (of the notesdocument class), a new unid is not generated for a document each time it is copied to a target database. if a copied document is deleted from the target database and then copied from the source a second time, the resulting document's unid will match the unid of the first document copied (within the target database ).

Example:
1. A document in a source database has the following unid (spaces added to login READING ):
86a84028 1de69507 85256a9d 005635d0

2. The copy generated by copytodatabase has the following unid (the last 16 characters match the original document's unid ):
E7271252 50d66fe4 85256a9d 005635d0

3. If the above copy is deleted and copied again, the unid is a duplicate of #2 above ):
E7271252 50d66fe4 85256a9d 005635d0

This can present an issue for some applications in which an agent copies documents, documents are being deleted, and replication is occurring, with the result being save/replication conflicts instead of actual documents.

Note: If the specified ENTs are manually copied from the source and pasted into the target database, then new unids are always generated. if a document is copied twice using the copytodatabase method without deleting the first one, the second copy will always have a new and unique unid.

Resolving the problem

This issue was reported to quality engineering as SPR # ashw4x9p8r and was fixed in Lotus Notes/Domino 6.0.4, 6.5.2, 7.0, and later releases, by the addition of an optional notes. INI parameter. the following notes. INI parameter forces a new unid to be created for a document after being copied to the destination database:

 

      Copytodatabase_new_unid = 1

Workaround for versions prior to 6.5.2 and 6.0.4:
If the copytodatabase method is used to copy the same document (to the same database) more than once, the additional document copies will be given entirely unique unids which will not repeat if the process itself is repeated. this fact can be used to work around this issue by calling the method twice and then removing the first document copied. the only possible detriment to the example below is the additional deletion stubs that are created. this method is still recommended as it is very straightforward and reliable.

      Set tempdoc = Doc. copytodatabase (db)
      Set newdoc = Doc. copytodatabase (db)
      Call tempdoc. Remove (true)

Supporting information
The design demo-for this behavior may be relative to the following: at times, performance issues have been observed when Id tables in a database become fragmented. retaining unid values was a design demo-to conserve unids for greater performance. deleting events and copying them back in is easier to do when writing an application but yields a greater fragmentation rate in a database, due to deletions and Adds.

Steps to reproduce

1. Create two databases: db1 and db2.

2. In both databases, create a view called unid and place steps a-d below into both views.

      A) Place this formula in the first column: @ text (@ documentuniqueid ).
      B) categorize the column in ascending order.
      C) Create a view-level action button named "Copy docs to DB2 ".
      D) paste the following code in the button (or similar LotusScript code ):
        Dim s as new notessession
        Dim db1 as notesdatabase
        Set db1 = S. currentdatabase
        Dim view1 as notesview
        Set view1 = db1.getview ("unid ")
        View1.refresh
        Dim DB2 as new notesdatabase ("servername", "database_2.nsf ")
        Dim doc as notesdocument
        Set Doc = view1.getfirstdocument
        While not (Doc is nothing)

          Call Doc. copytodatabase (DB2)
          Set Doc = view1.getnextdocument (DOC)

        Wend

3. Create a new form in db1 only and add any simple fields you want. Save and close.

4. Create one or more new documents using this form.

5. In the unid view of db1, click the button to copy these new documents to db2.

6. Open DB2 and look at the unids for the documents. Copy the number down or make a screen shot of them.

7. Delete the documents from db2.

8. Go back to db1 and click the button again to copy the documents to db2.

9. Open DB2 again and note the unids of the documents. They are the identical set of unids of the docs you deleted.

10. delete the document (s) from DB2 and use the button to copy the document (s) again. every time you copy over the document (s), the unids in DB2 will always be the same unids. if you copy the documents a second time without deleting them, a new set of unids is created.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.