add (NotesNoteCollection - JavaScript)

Adds one or more notes to a note collection.

Defined in

NotesNoteCollection

Syntax

add(removalspecifier:NotesAgent) : void

add(removalspecifier:NotesDocument) : void

add(removalspecifier:NotesDocumentCollection) : void

add(removalspecifier:NotesForm) : void

add(removalspecifier:int) : void

add(removalspecifier:NotesNoteCollection) : void

add(removalspecifier:string) : void

add(removalspecifier:NotesView) : void

Parameter Description
removalspecifier The note to be added. For int and string, the note ID; otherwise the associated object.

Usage

The parent database of the note(s) to add must be the same as the note collection.

Examples

This button builds a note collection of documents from the current database. It removes any document with a subject containing the text "example" then exports the revised collection as DXL.
// Open DXL file
var stream:NotesStream = session.createStream();
var filename:string = "c:\\dxl\\";
filename = filename + database.getFileName();
filename = filename.substring(0, filename.length() - 3) + "dxl";
if (stream.open(filename)) {
	requestScope.status = "Opened " + filename;
	stream.truncate();

	// Create note collection
	var nc:NotesNoteCollection = database.createNoteCollection(false);
	nc.buildCollection();
	
	// Add document if it contains word example
	var dc:NotesDocumentCollection = database.getAllDocuments();
	var doc:NotesDocument = dc.getFirstDocument();
	while (doc != null) {
		var  subject:string = doc.getItemValueString("Subject");
		if (subject.toLowerCase().indexOf("example") >= 0) {
			nc.add(doc.getNoteID());
		}
		var tmpdoc:NotesDocument = dc.getNextDocument(doc);
		doc.recycle();
		doc = tmpdoc;
	}

	// Export note collection as DXL
	var exporter:NotesDxlExporter = session.createDxlExporter();
	var output:string = exporter.exportDxl(nc);
	stream.writeText(output);
	stream.close();
	requestScope.status = requestScope.status + "\n" + nc.getCount() +
		" notes written to " + filename;
} else {
	requestScope.status = "Cannot open " + filename;
}