Notes client...
I could make a form with computed fields and create an agent or query open LS code to get the values and set the fields values.
I could create computed fields and do it with formula language but what a pain that would be.
The old way on the web
I would to use a webquery open agent and set the values, or compute formula on the fields.
Xpages...
Well in X-pages i am allowed to create a computed field and use SSJS to compute the value. It is like having a computed field on a client based notes form and setting the value to LS, which of course you cant do.
i wrote three lines of code per field
db = session.getCurrentDatabase()
view1 = db.getView('On Site')
view1.getEntryCount()
or it could be like
db = session.getCurrentDatabase()
view1 = db.getView('On Site')
dc1 = view1.getAllDocumentsByKey('test')
dc1.getCount()
and of course you can do a
db = session.getCurrentDatabase()
view1 = db.getView('On Site')
dc1= view1.getAllDocumentsByKey('test')
doc = dc1.getFirstDocument()
total = 0
while(doc != null)
{
total = doc.getItemValueDouble('amount') + total
set doc = dc1.getNextDocument(doc)
}
total.valueOf()
X-pages made this easy web development, compared to what i had to do in the past
2 comments:
Mark, you can save even one more line of code. :) The global variable "database" always refers to the session's current database, so you can skip straight to:
var view1 = database.getView('OnSite');
Global variables are evil, of course, but personally I like that IBM implemented a few globals that make sense, since we're almost guaranteed to need a handle on a few of these things on every page anyway (session, database, etc.).
Sweet did not know that, thanks!
Post a Comment