Copy or Move Documents

pts.
Tags:
Lotus Domino
Hi I need to copy or move set of documents from one nsf database to another nsf database at a stretch using lotus script method.As we do stampall for notescollection class. Thanks

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is a method that can be tailored to your specific needs:

Sub transferDocuments(MoveDocuments As Variant) ‘MoveDocuments: True -> Move, False -> Copy
‘This example will process all of the documents in a given view. You can be more specific if you need to be.
Dim lSession As NotesSession
Dim lTargetDB As NotesDatabase
Dim lSourceView As NotesView
Dim lDoc As NotesDocument
Dim lTempDoc As NotesDocument
Dim lTargetDBServer As String
Dim lTargetDBPath As String
Dim lSourceViewName As String

On Error Goto ErrorHandler

lTargetDBServer = Inputbox(“Enter the name of the target database server.”)
lTargetDBPath = Inputbox(“Enter the path of the target database.”)
lSourceViewName = Inputbox(“Enter the name (or alias) of the source view.”)

‘Connect to the target database
Set lTargetDB = New NotesDatabase(“”,””)
Call lTargetDB.Open(lTargetDBServer, lTargetDBPath)

‘Get a reference to the source view by getting a reference to the current database via the session object
Set lSession = New NotesSession
Set lSourceView = lSession.CurrentDatabase.GetView(lSourceViewName)

‘Start with the first document in the view
Set lDoc = lSourceView.GetFirstDocument
Do
‘Visual feedback – shows up in the status bar.
Print “Processing document ” & lDoc.NoteID

‘Copy the document to the target database
Set lTempDoc = lDoc.CopyToDatabase(lTargetDB)

‘Get a copy of the local document
Set lTempDoc = lDoc

‘Get a reference to the next document to copy from the source view
Set lDoc = lSourceView.GetNextDocument(lDoc)

If MoveDocuments Then
‘Remove the document from the current database
Call lTempDoc.Remove(False)
Call lSourceView.Refresh
End If
Loop Until lDoc Is Nothing

Print “Document transfer complete!”

ExitHere:

If lTargetDB.isOpen Then
Call lTargetDB.Close
End If

Set lTempDoc = Nothing
Set lDoc = Nothing
Set lSourceView = Nothing
Set lTargetDB = Nothing
Set lSession = Nothing

Exit Sub

ErrorHandler:
Messagebox “Error: ” & Err & Chr(10) & Error & ” occurred on line ” & Erl,, “Error transferring document between databases”
Resume ExitHere
End Sub

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • KavithaRao
    I dont want loop all the documents for coping a documents to another db. This has to done within one statment. As I mentioned already the method like stampall in notes document collection class. Hope you are getting my requirement. Anyway thanks Charles my requirement should not loop the document collection. Thanks
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following