XPages selected value work in XPiNC but not web browser
I'm doing the quick XAgent style view export to excel. But first I need to
get a the UNID of the documents that match the criteria that I selected on
my XPage. I have a button that will get the number of document found. I've
confirmed and verified that I have the documents based on the value that I
select but it always return zero document in the alert when in web
browser. For now the code in the button is as following:
uifrom = getComponent("from_dtpicker").getValue(); // a date-time picker
uito = getComponent("to_dtpicker").getValue(); // a date-time picker
uitag = getComponent("tag_combox").getValue(); // a combobox
var from:NotesDateTime = session.createDateTime(uifrom);
from.setAnyTime();
var to:NotesDateTime = session.createDateTime(uito);
to.setAnyTime();
var vw:NotesView = database.getView("(Document View by Tag)");
var docUNIDarray:Array = []; // for the quick XAgent excel export later on
if (uitag == "All") {
var vec:NotesViewEntryCollection = vw.getAllEntries();
} else {
var vec:NotesViewEntryCollection = vw.getAllEntriesByKey(uitag, true);
}
var total:Number = 0;
var ve:NotesViewEntry = vec.getFirstEntry();
while (ve != null) {
// document must have StartDate and EndDate
if (ve.getDocument().hasItem("StartDate") &&
ve.getDocument().hasItem("EndDate")) {
var vefrom:NotesDateTime =
ve.getDocument().getItemValue("StartDate").elementAt(0);
vefrom.setAnyTime();
// as long as the StartDate is between the selected from and to
if (vefrom >= from && vefrom <= to) {
if (ve.getDocument().getItemValueString("StaffName") !=
"Company") {
docUNIDarray.push(ve.getDocument().getUniversalID());
total += 1;
}
}
}
ve = vec.getNextEntry(ve);
}
view.postScript('alert("total:'+total+', from:'+from+', to:'+to+',
tag:'+uitag+'")');
Also, the only full refresh that I did is when clicking the button.
There's also no scoped variable in this page. Only 2 date-time picker, a
combobox, and the button itself. Any explanation for this? I'm confirmed
the code is correct because it work in XPiNC.
The total number of documents that I got is supposed to be 18. If I append
.toJavaDate() to from, to, and vefrom, then I get 10 documents which is
wrong. I've checked the underlying value of "StartDate" and "EndDate" for
each document and each value is of Time/Date like 08/12/2013 12:00:00 PM
ZE8. I assume that converting and any date value in my code to
NotesDateTime will ensure that all have the same type and can be compared
to but for this one I'm totally don't know what I did wrong.
No comments:
Post a Comment