getNthDocument (NotesDocumentCollection - JavaScript)

コレクション内の指定された位置にある文書を取得します。

定義場所

NotesDocumentCollection

構文

getNthDocument(n:int) : NotesDocument
パラメータ 説明
n 返される文書の位置を示す番号。 1 はコレクションの最初の文書、2 は 2 番目の文書というように文書を示します。
戻り値 説明
NotesDocument コレクション内の n 番目の位置にある文書。 指定された位置に文書がない場合は、NULL を返します。

使用法

文書が削除されると、コレクション内で番号が付け直され、削除された文書より後にあった文書の位置が変更されます。

パフォーマンス上の理由から、getNthDocumentgetCount を組み合わせてループを繰り返すことは避けてください。お勧めするループ構造については、getNextDocumentgetPrevDocument を参照してください。

以下のボタンは、文書の合計数を法として現在のデータベース内にある次の文書を取得します。グローバル変数は現在位置を指定します。
var dc:NotesDocumentCollection = database.getAllDocuments();
var n:int = sessionScope.documentNumber;
if (dc.getCount() > 0) {
	if (n == null || n == dc.getCount()) {
		n = 1;
	} else {
		n++;
	}
	var doc:NotesDocument = dc.getNthDocument(n);
	requestScope.status = doc.getItemValueString("subject");
	doc.recycle();
	sessionScope.documentNumber = n;
}

言語間の参照

LotusScript® NotesDocumentCollection クラスの GetNthDocument メソッド

Java™ DocumentCollection クラスの getNthDocument メソッド