CopyToDatabase script not working

Can’t get copytodatabase to work, any ideas what is wrong with this code?

Dim session As New NotesSession

Dim db As NotesDatabase

Dim db2 As New NotesDatabase(“”,“”)

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set doc = session.DocumentContext

Call db2.Open(db.Server,“directory\directory\filename.nsf”)

If db2.IsOpen Then

Print “DB2 opened OK…” - Works OK

Print db2.FilePath - Works OK

Print doc.Subject(0) - Works OK

Call doc.CopyToDatabase(db2) - FAILS, not copied, nothing written to log

Print “Doc copied OK…” - FAILS, Not printed

End If

End Sub

Running agent as web user(Manual/Hidden, trigger on event;agent list selection), user has full rights to both DBs, Agent triggered from wqs even on web form.

Subject: CopyToDatabase script not working

Hi

DocumentContext gives you the in-memory document.

Your problem is that you trying to copy a document which is not yet in the database. Call doc.save first before copying it.

brgds Jesper Kiaer

http://www.jezzper.com

Subject: RE: CopyToDatabase script not working

Added a save before the copy, no effect.

Got round it by creating a new doc in db2 using CopyAllItems, worked first time. Don’t think CopytoDatabase likes DocumentContext !!

Subject: RE: CopyToDatabase script not working

may be agent signer does not have “replicate or copy docs” privilege