Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Developing Applications > Developing XPage Applications > Developing XPage Applications for Notes Client > NotesViewEntry sample JavaScript code for XPages
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

NotesName sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesName. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesMIMEEntity sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesMIMEEntity. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesViewEntryCollection sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesViewEntryCollection. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesViewNavigator sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesViewNavigator. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.

NotesViewEntry sample JavaScript code for XPages

Here is sample JavaScript code for the class NotesViewEntry. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.
Community articleNotesViewEntry sample JavaScript code for XPages
Added by ~Elizabeth Umkroskiettu | Edited by ~Elizabeth Umkroskiettu on April 15, 2011 | Version 2
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
Here is sample JavaScript code for the class NotesViewEntry. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.
ShowTable of Contents
HideTable of Contents
    • 0.1 ChildCount
    • 0.2 ColumnIndentLevel
    • 0.3 ColumnValues
    • 0.4 DescendantCount
    • 0.5 Document
    • 0.6 FTSearchScore
    • 0.7 IndentLevel
    • 0.8 IsCategory
    • 0.9 IsConflict
    • 0.10 IsDocument
    • 0.11 IsTotal
    • 0.12 IsValid
    • 0.13 NoteID
    • 0.14 Parent
    • 0.15 SiblingCount
    • 0.16 UniversalID
    • 0.17 getPosition
    • 0.18 getRead

ChildCount


This button gets the first-column value and child count for the top-level entries in a view excluding the total.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null && !entry.isTotal()) {
	requestScope.status += "\n" +
	entry.getPosition(".") + " " +
	entry.getColumnValues().firstElement().toString() + " has" +
	entry.getChildCount().toFixed() + " immediate entries";
	var tmpentry:NotesViewEntry = nav.getNextSibling(entry);
	entry.recycle();
	entry = tmpentry;
}


ColumnIndentLevel


This button gets values for the entries in a view and indents them according to their indent level. For level 0, the first column value is used. For other levels, the second column value is used. Entries for response documents are omitted.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
	if (entry.getColumnIndentLevel() == 0) {
		var tabs:string = "";
		for (var i:int = 0; i < entry.getIndentLevel(); i++) {
			tabs = tabs + "\t";
		}
		var element:string = entry.getIndentLevel() == 0 ?
			entry.getColumnValues().firstElement().toString() :
			entry.getColumnValues().elementAt(1);
		requestScope.status += "\n" + tabs + element;
	}
	var tmpentry:NotesViewEntry = nav.getNext(entry);
	entry.recycle();
	entry = tmpentry;
}


ColumnValues


This button gets the first-column value and child count for the top-level entries in a view excluding the total.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null && !entry.isTotal()) {
	requestScope.status += "\n" +
	entry.getPosition(".") + " " +
	entry.getColumnValues().firstElement().toString() + " has" +
	entry.getChildCount().toFixed() + " immediate entries";
	var tmpentry:NotesViewEntry = nav.getNextSibling(entry);
	entry.recycle();
	entry = tmpentry;
}


DescendantCount


This button gets the first-column value and descendant count for the top-level entries in a view excluding the total.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null && !entry.isTotal()) {
	requestScope.status += "\n" +
	entry.getPosition(".") + " " +
	entry.getColumnValues().firstElement().toString() + " has" +
	entry.getDescendantCount().toFixed() + " total entries";
	var tmpentry:NotesViewEntry = nav.getNextSibling(entry);
	entry.recycle();
	entry = tmpentry;
}


Document


This button gets the last accessed time for a view entry.

var bycat:NotesView = database.getView("main");
if (requestScope.query.isEmpty()) return;
var entry:NotesViewEntry = bycat.getEntryByKey(requestScope.query);
if (entry == null || entry.getDocument() == null) {
	requestScope.status = "Invalid entry";
	return;
}
requestScope.status = entry.getColumnValues().firstElement() + " last accessed on " +
entry.getDocument().getLastAccessed().getLocalTime();


FTSearchScore


This computed field returns information on entries found from a full-text search, including their search scores.

database.updateFTIndex(true);
var v:NotesView = database.getView("By category");
var vec:NotesViewEntryCollection = v.getAllEntries();
vec.FTSearch(requestScope.query);
var entry:NotesViewEntry = vec.getFirstEntry();
while (entry != null) {
	requestScope.status += "\n" +
	entry.getColumnValues().elementAt(1).toString() + " (" +
	entry.getFTSearchScore().toFixed() + ")";
	var tmpentry:NotesViewEntry = vec.getNextEntry(entry);
	entry.recycle();
	entry = tmpentry;
}


IndentLevel


This button gets values for the entries in a view and indents them according to their indent level. For level 0, the first column value is used. For other levels, the second column value is used.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
	var tabs:string = "";
	for (var i:int = 0; i < entry.getIndentLevel(); i++) {
		tabs = tabs + "\t";
	}
	var element:string = entry.getIndentLevel() == 0 ?
		entry.getColumnValues().firstElement().toString() :
		entry.getColumnValues().elementAt(1);
	requestScope.status += "\n" + tabs + element;
	var tmpentry:NotesViewEntry = nav.getNext(entry);
	entry.recycle();
	entry = tmpentry;
}


IsCategory


This button gets the entries from a categorized view, displaying the first column if the entry is a category and a document item if the entry is a document.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
	if (entry.isCategory()) {
		requestScope.status += "\n" + 
		entry.getColumnValues().firstElement().toString();
	} else if (entry.isDocument()) {
		requestScope.status += "\n\t" + 
		entry.getDocument().getItemValueString("subject");
	}
	var tmpentry:NotesViewEntry = nav.getNext(entry);
	entry.recycle();
	entry = tmpentry;
}


IsConflict


This button gets the entries from a categorized view, displaying the first column if the entry is a category and a document item if the entry is a document, and marking conflict documents.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
	if (entry.isCategory()) {
		requestScope.status += "\n" + 
		entry.getColumnValues().firstElement().toString();
	} else if (entry.isDocument()) {
		requestScope.status += "\n\t" + 
		entry.getDocument().getItemValueString("subject");
		if (entry.isConflict()) {
			requestScope.status += " [conflict document]"
		}
	}
	var tmpentry:NotesViewEntry = nav.getNext(entry);
	entry.recycle();
	entry = tmpentry;
}


IsDocument


This button gets the entries from a categorized view, displaying the first column if the entry is a category and a document item if the entry is a document.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
	if (entry.isCategory()) {
		requestScope.status += "\n" + 
		entry.getColumnValues().firstElement().toString();
	} else if (entry.isDocument()) {
		requestScope.status += "\n\t" + 
		entry.getDocument().getItemValueString("subject");
	}
	var tmpentry:NotesViewEntry = nav.getNext(entry);
	entry.recycle();
	entry = tmpentry;
}


IsTotal


This button gets the first-column value and child count for the top-level entries in a view excluding the total.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null && !entry.isTotal()) {
	requestScope.status += "\n" +
	entry.getPosition(".") + " " +
	entry.getColumnValues().firstElement().toString() + " has" +
	entry.getChildCount().toFixed() + " immediate entries";
	var tmpentry:NotesViewEntry = nav.getNextSibling(entry);
	entry.recycle();
	entry = tmpentry;
}


IsValid


This button gets the entries from a categorized view, displaying the first column if the entry is a category and a document item if the entry is a document, and marking non-valid documents.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
	if (entry.isCategory()) {
		requestScope.status += "\n" + 
		entry.getColumnValues().firstElement().toString();
	} else if (entry.isDocument()) {
		requestScope.status += "\n\t" + 
		entry.getDocument().getItemValueString("subject");
		if (!entry.isValid()) {
			requestScope.status += " [is not valid]";
		}
	}
	var tmpentry:NotesViewEntry = nav.getNext(entry);
	entry.recycle();
	entry = tmpentry;
}


NoteID


This button writes the document note ID for a view entry to a global variable.

var bycat:NotesView = database.getView("main");
if (requestScope.query.isEmpty()) return;
var entry:NotesViewEntry = bycat.getEntryByKey(requestScope.query);
if (entry == null || entry.getDocument() == null) {
	requestScope.noteid = null;
	return;
}
requestScope.noteid = entry.getNoteID();


This computed field uses the note ID to display the value of an item in the document.

if (requestScope.noteid == null) {
	return null;
}
var doc:NotesDocument = database.getDocumentByID(requestScope.noteid);
return doc.getItemValueString("subject");


Parent


This button assigns a view entry to a global variable.

var bycat:NotesView = database.getView("main");
if (requestScope.query.isEmpty()) return;
var entry:NotesViewEntry = bycat.getEntryByKey(requestScope.query);
if (entry == null || entry.getDocument() == null) {
	requestScope.unid = null;
	return;
}
requestScope.entry = entry;


This computed field uses the global variable to get the name of the parent view.

var entry = requestScope.entry;
if (entry == null) {
	return null;
} else {
		return entry.getParent().getName();
}


SiblingCount


This computed field returns the number of categories for a view by getting the first entry and counting the siblings.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
return "Number of categories: " + entry.getSiblingCount();


UniversalID


This button writes the document universal ID for a view entry to a global variable.

var bycat:NotesView = database.getView("main");
if (requestScope.query.isEmpty()) return;
var entry:NotesViewEntry = bycat.getEntryByKey(requestScope.query);
if (entry == null || entry.getDocument() == null) {
	requestScope.unid = null;
	return;
}
requestScope.unid = entry.getUniversalID();


This computed field uses the universal ID to display the value of an item in the document.

if (requestScope.unid == null) {
	return null;
}
var doc:NotesDocument = database.getDocumentByID(requestScope.unid);
return doc.getItemValueString("subject");


getPosition


This button gets the position, first-column value, and child count for the top-level entries in a view excluding the total.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null && !entry.isTotal()) {
	requestScope.status += "\n" +
	entry.getPosition(".") + " " +
	entry.getColumnValues().firstElement().toString() + " has" +
	entry.getChildCount().toFixed() + " immediate entries";
	var tmpentry:NotesViewEntry = nav.getNextSibling(entry);
	entry.recycle();
	entry = tmpentry;
}


getRead


This button indicates whether each document in a view is read.

var nav:NotesViewNavigator = database.getView("By category").createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
	if (entry.isCategory()) {
		requestScope.status += "\n" + 
		entry.getColumnValues().firstElement().toString();
	} else if (entry.isDocument()) {
		requestScope.status += "\n\t" + 
		entry.getDocument().getItemValueString("subject");
		if (entry.getRead()) {
			requestScope.status += " [has been read]";
		} else {
			requestScope.status += " [has not been read]";
		}
	}
	var tmpentry:NotesViewEntry = nav.getNext(entry);
	entry.recycle();
	entry = tmpentry;
}

  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (2)
collapsed Versions (2)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (2)Apr 15, 2011, 2:24:16 PM~Elizabeth Umkroskiettu  
1Feb 14, 2011, 2:56:23 PM~Ben Eljipypulettu  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility