Notes In 9 – 019 – Xpages: Getting Column Totals From a View

It’s been a little while. I’m glad to be back and look forward to getting some more shows out in the next several weeks. Lots of ideas in the “queue”. :-)

This show starts out with some announcements and details of some Free and Paid training options for XPages that are available in August.

For the technical portion of the show, I give a demo on how to use Server Side JavaScript (SSJS) to retrieve a categorized column total and put it on an XPage.

The code for the main example is:

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];
}

Links:
IamLUG
MWLug
Tack It On

  • Ryan

    Hi David,

    This helped me out a ton. Thank you. I had a question though regarding sub-categories…

    I have a table that looks like this: http://dl.dropbox.com/u/40159/example.png

    What if I need to get the value of the 2011 category ’27′. getPrev(entry) only gets me the ’24′. Any ideas?

  • Chris_warden

    This is awesome and most appreciated.

    Of course, I have a question about the simplest part. What type of control is the key at the top of the form and what event are you using to put the value of the key into the sessionScope variable?

  • http://twitter.com/DavidLeedy DavidLeedy

    Are you more interested in the “show Single Category” portion? Not the column totals that was the purpose of the show? It sounds like it… I don’t know if I have the db for this show handy. I can check. But I think I went over the “show Single Category” a couple of times. Likely in show 18: Data Relationships and also one of the Jumpstart shows.
    If that doesn’t help let me know and I’ll re-dig into this.

  • http://twitter.com/DavidLeedy DavidLeedy

    Sorry I didn’t see this when you posted it. I’ve not tried this at all yet. Quite honestly I THINK I’d be included to try and build this using nested repeat controls… rather then a view control.
    But I would think using the domino objects you could drill down as demo’d in the show to get the deeper level column. But again I can’t say that I’ve tried it. I would suggest that if this is still an issue. Use the object model to try and get the desired value in LotusScript. Assuming you can, which I think should be doable, it’s probably pretty easy to then translate that into SSJS.
    Again – Sorry I didn’t see you comment sooner.

  • Chris_warden

    I am still having 2 problems to make this work.

    1. I do not know where to put the code to put the sessionScope key
    2. I do not know how to set up the initial document/view that shows the key + the totals from the Xpage you created.

    I would really appreciate further help as it is exactly what I need to solve a problem of mine. I got the view in the XPage document to use the computed labels to get the computed column totals but I need to go from there to the final report.

    I keep getting a web handle error

    Thanks

    Chris Warden

  • Guest

     It’s really a nice and helpful piece of information.Long time no see so excellent article, and I am very interested in your article, but also very much hope you can come to visit our websiteshoppingpandora&Pandora Charm Collection