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.
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