I’m looking for a way using a repeat control to get the last 20 documents from an Inbox folder.
Currently I have my repeat control getting 20 documents, but it gets it from the top of the Inbox, not the bottom. Is there a parameter I can set in either the data control or the repeat control to specify a sort order or perhaps another way?
Thanks,
Dan
Subject: Here’s one method
In your repeat control set the data binding Iteration to Javascript and enter something like the following as the SSJS code. This gets a collection of the the last 20 documents in the view and returns them to the repeat control.
var db:NotesDatabase = session.getCurrentDatabase();
var view:NotesView = db.getView("ViewName");
var dc:NotesDocumentCollection = db.getProfileDocCollection("GiveMeAnEmptyCollection")
var doc:NotesDocument;
var max:integer;
if (view.getEntryCount() > 20){
max = 20;
}else{
max = view.getEntryCount();
}
if (max > 0) {
doc = view.getLastDocument();
for ( var i=1;i<=max;i++ ){
dc.addDocument(doc);
doc = view.getPrevDocument(doc);
}
}
return dc;
Subject: thanks! that worked!
I appreciate the help! It worked, I just had to change any code within the repeat such as:
rowData.getDocument().getItemValueString(“field…”)
to -
rowData.getItemValueString(“field…”)
since it was already referenced as a notesdocument. Other than that your solution was perfect.
thanks,
Dan