evaluate (NotesSession - JavaScript)

Evaluates a Domino® formula.

Defined in

NotesSession

Syntax

evaluate(formula:string) : java.util.Vector

evaluate(formula:string, doc:NotesDocument) : java.util.Vector

Parameter Description
formula The formula.
doc The formula context. Cannot be null.
Return value Description
java.util.Vector The result of the evaluation. A scalar result is returned in firstElement.

Usage

If the formula contains the name of a field, you must use the 2-parameter method. The formula takes the field from the document specified as parameter 2.

@Functions that affect the user interface do not work in evaluate. These include: @Command, @DbManager, @DbName, @DbTitle, @DDEExecute, @DDEInitiate, @DDEPoke, @DDETerminate, @DialogBox, @PickList, @PostedCommand, @Prompt, and @ViewTitle.

You cannot change a document with evaluate; you can only get a result. To change a document, write the result to the document with a method such as NotesDocument.replaceItemValue.

Examples

This button changes the subject item of all documents in a database view to proper case.
var view:NotesView = database.getView("main");
var doc:NotesDocument = view.getFirstDocument();
while (doc != null) {
	var eval = session.evaluate("@ProperCase(subject)", doc);
	doc.replaceItemValue("subject", eval);
	doc.save();
	tmpdoc = view.getNextDocument(doc);
	doc.recycle();
	doc = tmpdoc;
}