Getting Total Value from View column


Am Puzzled, So I looking to you guys , Here is what am trying to do.

Getting Total amount  from a flat view with one Column that keeps Total Sales of many documents.

Getting Total sale into a XPages form using computedField

I have tried this

var key = viewRow.getColumnValue(“Totalsale”);
var lookup = @DbLookup(@DbName(), “MyTotelSale”, key, 12);
return lookup

and from Notesin9 from my friend David. His solution is based on Key and its works like a charm where i use a KEY. but not in this case.

var cView:NotesView = database.getView(“vOrders”);
var nav:NotesViewNavigator = cView.createViewNav();

// Since you can’t do ‘getCategory’ – find the first doc and backup 1
var entry:NotesViewEntry = cView.getEntryByKey(sessionScope.get(“key”));
entry = nav.getPrev(entry);
if (entry == null) {
// Nothing to Do
}
else {
return entry.getColumnValues()[2];
}

Any idea how to get this value ?

 UPDATE – David Leedy got hold of me and we did a short gotomeeting so he could see the issue  ( my post was not clear , writing this just before the game)  and he came up with a solution

Am not using repeat but this works . by using getlast() I was able to get the total Value.

THANKS David I really appreciate  your help.

<xp:repeat id=”repeat1″ rows=”30″ var=”rowData”>
<xp:this.value><![CDATA[#{javascript:var myView:NotesView = database.getView(“byUnique”);
var nav:NotesViewNavigator = myView.createViewNav();
var entry:NotesViewEntry = nav.getLast();
return entry.getColumnValues()}]]></xp:this.value>
<xp:text escape=”true” id=”computedField1″
value=”#{javascript:rowData}”>
</xp:text>
<xp:br></xp:br>
</xp:repeat>

 

I change this to be

var myView:NotesView = database.getView(“MySalesTotal”);
var nav:NotesViewNavigator = myView.createViewNav();
var entry:NotesViewEntry = nav.getLast();
return entry.getColumnValues()[12];

 

congrats to Germany 🙂 Great game

Advertisements

8 thoughts on “Getting Total Value from View column

  1. Hi,

    I am using the code for my app, and it is getting just the last value, not the total. Why?

    Thanks.

    • I have a view, with a column of coins, and then under the view, in XPage, a label with the code.

  2. Florin, do the following : open the view that you are pulling the total from in designer , then double click on the column that you are using in the Xpages view , there you will have some options , on second tab you see at bottom total and you will see there in the drop down some option , one is Total , it should be the first one, select it and save , then the code should work

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s