copyToDatabase (NotesDocument - JavaScript)

Copies a document to a specified database.

Defined in

NotesDocument

Syntax

copyToDatabase(db:NotesDatabase) : NotesDocument
Parameter Description
db The database to which you want to copy the document. Cannot be null.
Return value Description
NotesDatabase The new document in the specified database.

Usage

CopyToDatabase also saves the new document.

Examples

This button creates an archive of the main view in the current database.
try {
	var newdb:NotesDatabase = database.createCopy(null,  + "archive_" + database.getFileName());
} catch(e) {
	requestScope.status = "Error: cannot create archive";
	return;
}
newdb.setTitle("Copy of " + database.getTitle());
requestScope.status = "Archive created\n";
var view:NotesView = database.getView("main");
var doc:NotesDocument = view.getFirstDocument();
var count:int = 0;
while (doc != null) {
	doc.copyToDatabase(newdb);
	count++;
	var tmpdoc = view.getNextDocument(doc);
	doc.recycle(); // recycle to avoid memory problems
	doc = tmpdoc;
}
requestScope.status += count + " documents copied to archive";