getPrevSibling (NotesView - JavaScript)

Given a document in a view, returns the document immediately preceding it at the same level. If you use this method on a main document, the preceding main document in the view is returned. If you use it on a response document, the preceding response document with the same parent is returned. If the view is categorized, the previous sibling is in the same category as the original document.

Defined in

NotesView

Syntax

getPrevSibling(doc:NotesDocument) : NotesDocument
Parameter Description
doc Any document in the view. Cannot be null.
Return value Description
NotesDocument The document preceding the parameter, at the same level. Returns null if there is no previous sibling in the view.

Usage

You can use getPrevSibling to move from one main document to the next, skipping any response documents in between.

If you filtered the view using FTSearch, getPrevSibling returns the previous document in the view regardless of level.

Two documents are siblings if:
  • They are both main documents.
  • They are both responses or response-to-responses and share the same parent document.
This method returns null when the parameter is:
  • The first main document in a view.
  • The first response (or response-to-response) to a particular parent.

Examples

This button gets all the top-level documents in a view in reverse order.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getLastDocument();
while (doc.isResponse()) {
	doc = v.getParentDocument(doc);
}
while (doc != null) {
	requestScope.status += "\n" + doc.getItemValueString("subject");
	tmpdoc = v.getPrevSibling(doc);
	doc.recycle();
	doc = tmpdoc;
}