August 06, 2007

Evaluate in Java

Something I didn't know is that the evaluate function that is used in lotusscript to take advantage of the power of formulas also can be used in Java agents or script libraries in the notes client. There is a slight difference though:

Here's how it's used in Lotusscript. An array of strings is returned:
strArray=Evaluate(|@Unique(@DbColumn("":"ReCache"; "":""; "summaries"; 1))|)

In Java you make use of the session object to get the evaluate function. A vector is returned. Note that you replace the pipes (|) with (").
Vector v=session.evaluate("@Unique(@DbColumn('':'ReCache'; '':''; 'summaries'; 1))");

To loop through the vector and use the values as strings, do something like this:
for (int i=0; i<v.size(); i++) {
System.out.println(v.elementAt(i));
}


Read more and see examples of the evaluate function on notessidan.

Technorati tags:
, , ,


2 comments:

Bryan Kuhn said...

nice tip, have you put this into play in any web apps or is this strictly an example.

Niklas Waller said...

I have used it successfully in a notes app but I didn't print it as in the example. It was used to get a column with names from a view and to put each name in a sendTo field in a mail doc I created to send one by one.
It should work for a web app as well!