Lotus Notes 7 - copy / move docs. ( parent & response docs ) without changing the UNID ?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 22:40:06

Yes, copying a document to another database always creates a new UniversalIDs for document in target database.

To avoid this, your LotusScript should work like this:

  • create new document in target database
  • CopyAllItems from source document to target document
  • set same UniversalID to target document targetDoc.UniversalID = sourceDoc.UniversalID
  • save the target document

This way the target document has the same UniversalID like the source document and links between document should work in target database too.

This is an example for an agent working on selected documents:

Dim session As New NotesSession
Dim dbSource As NotesDatabase
Dim dbTarget As NotesDatabase
Dim col As NotesDocumentCollection
Dim docSource As NotesDocument
Dim docTarget As NotesDocument

Set dbSource = session.Currentdatabase
Set dbTarget = session.Getdatabase(dbSource.Server, "YourTargetDatabase.nsf", false)
Set col = dbSource.Unprocesseddocuments
Set docSource = col.Getfirstdocument()
While Not docSource Is Nothing
    Set docTarget = dbTarget.Createdocument()
    Call docSource.Copyallitems(docTarget, true)
    docTarget.UniversalID = docSource.UniversalID
    Call docTarget.save(True, False)
    Set docSource = col.Getnextdocument(docSource)
Wend

Or, you could let replication handle this for you by setting a replication formula, assuming that dbA and dbB are replicas.

I think the easiest way is creating a script and copiing the documents using the CopyToDatabase method of NotesDocument class. The CopyToDatabase method retains the UniversalID of documents (for perfomance reasons). This is true at least for Versions up to R7.

More information can be found here: IBM Technote: Documents copied using CopyToDatabase method reuse same UNID

A sample Script (copied and modified from Knut) would be:

Dim session As New NotesSession
Dim dbSource As NotesDatabase
Dim dbTarget As NotesDatabase
Dim col As NotesDocumentCollection
Dim docSource As NotesDocument
Dim docTarget As NotesDocument

Set dbSource = session.Currentdatabase
Set dbTarget = session.Getdatabase(dbSource.Server, "YourTargetDatabase.nsf", false)
Set col = dbSource.Unprocesseddocuments
Set docSource = col.Getfirstdocument()
While Not docSource Is Nothing
    Set docTarget = docSource.Copytodatabase(dbTarget)
    Set docSource = col.Getnextdocument(docSource)
Wend
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!