Lotus Notes 7 - copy / move docs. ( parent & respo

2019-05-16 23:23发布

I have 2 databases : let say dbA and dbB. Actually, dbB is a ''child'' database of dbA, because the forms/views/frameset/etc that it contains they all are also in dbA.

I want now, to copy from a view ( let say vwA ) from dbA some 8K docs to the same view ( vwA ) from dbB. THese 8k contains both parent and child docs, which in dbA are listing OK, with @Text(@UniqueDocumentID). I just made a test, copy one parent doc and its response, and pasted in the 2nd database, but unfortunately the connection between the 2 docs isn't made... I guess the UNID had changed...

Is there any solutions? Thanks for your time.

3条回答
男人必须洒脱
2楼-- · 2019-05-17 00:02

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

查看更多
看我几分像从前
3楼-- · 2019-05-17 00:07

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
查看更多
等我变得足够好
4楼-- · 2019-05-17 00:22

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
查看更多
登录 后发表回答