deleteDocument (NotesDocumentCollection - JavaScript)

Deletes a document from a collection.

Defined in

NotesDocumentCollection

Syntax

deleteDocument(doc:NotesDocument) : void
Parameter Description
doc The document to be deleted. Cannot be null.

Usage

This method throws an exception if:
  • The document is already deleted.
  • The document cannot be retrieved from this collection.
  • The document collection is the result of a multi-database full-text search.

Examples

This button intersects two collections based on two searches.
var dc:NotesDocumentCollection = database.getAllDocuments();
var dc2:NotesDocumentCollection = dc.cloneCollection();
var query:string = requestScope.query;
var query2:string = requestScope.query2;
if (!query.isEmpty()) {
	query = "\"" + query + "\"";
	database.updateFTIndex(true);
	dc.FTSearch(query);
	if (!query2.isEmpty()) {
		query2 = "\"" + query2 + "\"";
		dc2.FTSearch(query2);
		var doc2:NotesDocument = dc2.getFirstDocument();
		while (doc2 != null) {
			// Delete document from second query if it is not in first
			var tmpdoc2 = dc2.getNextDocument();
			if (dc.getDocument(doc2) == null) {
				dc2.deleteDocument(doc2);
			}
			doc2.recycle();
			doc2 = tmpdoc2;
		}
	}
	requestScope.status = "Query results:";
	var doc:NotesDocument = dc2.getFirstDocument();
	while (doc != null) {
		requestScope.status += "\n" + doc.getItemValueString("subject");
		var tmpdoc = dc2.getNextDocument();
		doc.recycle();
		doc = tmpdoc;
	}
} else {
	requestScope.status = "No query";
}