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 > NotesViewEntryCollection 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 articleNotesViewEntryCollection 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 NotesViewEntryCollection. Eventually this sample code will find its way into the documentation. Corrections and comments are appreciated.
ShowTable of Contents
HideTable of Contents
    • 0.1 Count
    • 0.2 Parent
    • 0.3 Query
    • 0.4 addEntry
    • 0.5 cloneCollection, merge
    • 0.6 contains, deleteEntry
    • 0.7 FTSearch
    • 0.8 getEntry
    • 0.9 getFirstEntry, getNextEntry
    • 0.10 getLastEntry, getPrevEntry
    • 0.11 getNthEntry
    • 0.12 intersect
    • 0.13 markAllRead
    • 0.14 markAllUnread
    • 0.15 putAllInFolder
    • 0.16 removeAll
    • 0.17 removeAllFromFolder
    • 0.18 stampAll
    • 0.19 subtract

Count


This computed field displays the number of documents in a view.

return database.getView("main").getAllEntries().getCount().toFixed()


Parent


This computed field displays the name of the parent view of a view entry collection defined elsewhere on the page.

if (requestScope.vec != null) {
	var view:NotesView = requestScope.vec.getParent();
	return view.getName();
}


Query


This computed field displays the query associated with a view entry collection defined elsewhere on the page.

var query:string = "";
if (requestScope.vec != null)
	query = requestScope.vec.getQuery();
return query.isEmpty() ? "No query" : query;


addEntry


This button puts in a folder documents found through a search plus the current document.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
if (vec.getCount() > 0) {
	var doc:NotesDocument = currentDocument.getDocument();
	if (doc != null) vec.addEntry(doc, true);
	vec.putAllInFolder("searchResults", true);
	requestScope.status = "Document(s) put in folder";
} else {
	requestScope.status = "No match";
}


cloneCollection, merge


This button gets all documents in a view that match either of two user search queries.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec1:NotesViewEntryCollection = database.getView("main").getAllEntries();
var vec2:NotesViewEntryCollection = vec1.cloneCollection();
vec1.FTSearch(requestScope.query);
vec2.FTSearch(requestScope.query2);
vec1.merge(vec2);
if (vec1.getCount() > 0) {
	var entry:NotesViewEntry = vec1.getFirstEntry();
	while (entry != null) {
		requestScope.status += "\n" + 
			entry.getDocument().getItemValueString("subject");
		entry = vec1.getNextEntry(entry);
	}
} else {
	requestScope.status = "No match";
}


contains, deleteEntry


This button puts in a folder documents found through a search minus the current document.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
if (vec.getCount() > 0) {
	var doc:NotesDocument = currentDocument.getDocument();
	var entry:NotesViewEntry = vec.getEntry(doc);
	if (vec.contains(entry)) {
		vec.deleteEntry(entry);
	}
	vec.putAllInFolder("searchResults", true);
	requestScope.status = "Document(s) put in folder";
} else {
	requestScope.status = "No match";
}


FTSearch


This button gets the first entry in a view that matches a user search query.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query, 1);
var entry:NotesViewEntry = vec.getFirstEntry();
requestScope.status = entry != null ?
	entry.getPosition(".") + " " + entry.getDocument().getItemValueString

("subject") :
	"No match";


getEntry


This button gets the position of the current document in a view.

var doc:NotesDocument = currentDocument.getDocument();
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
var entry:NotesViewEntry = vec.getEntry(doc);
requestScope.status = entry.getPosition(".") + " " + doc.getItemValueString

("subject");


getFirstEntry, getNextEntry


This button gets all the documents in a view.

var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
var entry:NotesViewEntry = vec.getFirstEntry();
while (entry != null) {
	var subject:string = entry.getDocument().getItemValueString("subject");
	requestScope.status += "\n" + subject;
	var tmpentry:NotesViewEntry = vec.getNextEntry(entry);
	entry.recycle();
	entry = tmpentry;
}


getLastEntry, getPrevEntry


This button gets all the documents in a view in reverse order.

var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
var entry:NotesViewEntry = vec.getLastEntry();
while (entry != null) {
	var subject:string = entry.getDocument().getItemValueString("subject");
	requestScope.status += "\n" + subject;
	var tmpentry:NotesViewEntry = vec.getPrevEntry(entry);
	entry.recycle();
	entry = tmpentry;
}


getNthEntry


This button gets the document in a view at a specified position.

var n:int = parseInt(requestScope.query);
if (isNaN(n)) {
	requestScope.status = "Not a number";
	return;
}
var mainview:NotesView =database.getView("main");
var vec:NotesViewEntryCollection = mainview.getAllEntries();
var entry:NotesViewEntry = vec.getNthEntry(n);
if (entry == null) {
	requestScope.status = "No document at that position";
	return;
}
requestScope.status = entry.getDocument().getItemValueString("subject");


intersect


This button gets all documents in a view that match two user search queries.

if (requestScope.query.isEmpty()) return;
if (requestScope.query2.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec1:NotesViewEntryCollection = database.getView("main").getAllEntries();
var vec2:NotesViewEntryCollection = vec1.cloneCollection();
vec1.FTSearch(requestScope.query);
vec2.FTSearch(requestScope.query2);
vec1.intersect(vec2);
if (vec1.getCount() > 0) {
	var entry:NotesViewEntry = vec1.getFirstEntry();
	while (entry != null) {
		requestScope.status += "\n" + 
			entry.getDocument().getItemValueString("subject");
		entry = vec1.getNextEntry(entry);
	}
} else {
	requestScope.status = "No match";
}


markAllRead


This button marks as read all documents in a view that match a user search query.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
var n:int = vec.getCount();
if (n > 0) {
	vec.markAllRead();
	requestScope.status = n.toFixed() + " document(s) marked as read"; 
} else {
	requestScope.status = "No match";
}


markAllUnread


This button marks as read all documents in a view that match a user search query.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
var n:int = vec.getCount();
if (n > 0) {
	vec.markAllUnread();
	requestScope.status = n.toFixed() + " document(s) marked as unread"; 
} else {
	requestScope.status = "No match";
}


putAllInFolder


This button puts in a folder all documents in a view that match a search query.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
if (vec.getCount() > 0) {
	vec.putAllInFolder("searchResults", true)
	requestScope.status = "Document(s) put in folder";
} else {
	requestScope.status = "No match";
}


removeAll


This button removes all documents in a view that match a search query.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
if (vec.getCount() > 0) {
	vec.removeAll(true);
	requestScope.status = "Document(s) removed";
} else {
	requestScope.status = "No match";
}


removeAllFromFolder


This button removes from a folder all documents in a view that match a search query.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
if (vec.getCount() > 0) {
	vec.removeAllFromFolder("searchResults")
	requestScope.status = "Document(s) removed from folder";
} else {
	requestScope.status = "No match";
}


stampAll


This button stamps all documents in a view that match a search query.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
if (vec.getCount() > 0) {
	vec.stampAll("status", "obsolete");
	requestScope.status = "Document(s) stamped";
} else {
	requestScope.status = "No match";
}


subtract


This button puts in a folder documents found through a search minus the current document.

if (requestScope.query.isEmpty()) return;
if (!database.isFTIndexed()) database.createFTIndex(0, false);
var vec:NotesViewEntryCollection = database.getView("main").getAllEntries();
vec.FTSearch(requestScope.query);
if (vec.getCount() > 0) {
	var doc:NotesDocument = currentDocument.getDocument();
	if (doc != null) vec.subtract(doc);
	vec.putAllInFolder("searchResults", true);
	requestScope.status = "Document(s) put in folder";
} else {
	requestScope.status = "No match";
}

  • 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:47 PM~Elizabeth Umkroskiettu  
1Mar 8, 2011, 9:26:51 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