Hi Paul,
The data is used in Repeats and Computed Fields sometimes it is used for the JSON values for charts. This example simply produces a column of our top 30 spending customers. The data is collected from 2 views, a view of invoices categorised on the partent ID (the account ID) along with a second view of Accounts to extract the name from the ID. In this instance we are only using the sub totals rather than each entry, however, the time to generate the table, - or chart, if we then format to provide JSON format. for use in a chart, - is around 60 seconds. 30 results are returned as the repeat has 30 rows. Other examples use all of the data for Pie Charts.
This is a typical example, my objective it to try to carry out the process overnight and then point the results at a system stored variable of field to eliminate the processing during the day.
<xp:repeat id="repeat1" rows="30" var="rowDataSpend">
<xp:this.value><![CDATA[#{javascript:var db:NotesDatabase = session.getDatabase("Titan", "NCLCMS.nsf", false);
var v = db.getView("($ xPages Invoices By Account)");
var nav:NotesViewNavigator = v.createViewNav();
var entry:NotesViewEntry = nav.getFirst();
var vAccnt = db.getView("($ xPages Accounts by ID)");
var values = []; // create an empty array
while (entry!=null && !entry.isTotal()){
var obj={};
var acctID = entry.getColumnValues().get(0);
obj.account= vAccnt.getEntryByKey(acctID).getColumnValues().get(1);
obj.total=entry.getColumnValues().get(1);
values.push(obj);
var tmpentry:NotesViewEntry = nav.getNextSibling(entry);
entry.recycle();
entry = tmpentry;
}
// define comparator function, sorts by lastname + firstname
var comparator = function(a,b){
var v1 = a.total;
var v2 = b.total;
if (v1 > v2)
return -1;
else if (v1 < v2)
return 1;
else
return (a.total).compareTo(b.total);
}
values.sort(comparator)
}
]]></xp:this.value>
<xp:text escape="true" id="computedField3" value="#{javascript:rowDataSpend.account}"></xp:text>
</xp:panel>
<xp:panel styleClass="col2CS">
<xp:text escape="true" id="computedField4" value="#{javascript:rowDataSpend.total}">
</xp:text>
</xp:repeat>