views:

32

answers:

1

Hi All,

Here's a tough one for you: I have a NotesForm object and I got the entire structure, including default values for fields, of which some are formulas. Now, I am creating some NotesDocument objects for that form using code. I have no idea of the structure of the NSF beforehand - only at runtime, The databse can come from anywhere. So, that means I also don't know what the formula is either.

Now, what I want to know is: Is there a way I can pass some formula text that I have read from a default value (for example: @Today) to Notes and get the result back for that formula? Then I can use that value when generating my document. As it stands, these fields are blank when they could perfectly well have had a default value if they had been entered via the Notes client.

Any ideas?

Thanks in advance

+3  A: 

You can use the Evaluate function/method. If you are operating from LotusScript within the Notes/Domino environment, you can use something like this:

Dim result As Variant
result = Evaluate(formulaString [,doc])

The NotesDocument object, doc int the above snippet, is optional but necessary if you are evaluating a formula that uses data from a specific document. You wouldn't need to use it to evaluate @Today, but if your formula uses a value from another field, then you need to tell the formula language engine which document to use (it doesn't have the context hint it would have in a "pure formula" situation).

If you are using COM or Java, the Evaluate statement isn't part of the language, so it is addressed as a method of the Notes session object.

Evaluate returns a Variant natively, usually containing an Array (it may also return an error value). In LotusScript, use a Variant and take the zeroth index if you are expecting a single scalar value back. In VB classic or VBA, it will be a Variant. In .NET, it's an Object; in Java it will be a vector.

Stan Rogers
Stan... you are a genius. No, I am not operating from within the notes environment, BUT the Evaluate method exists on the NotesSession object. Thank you 1000 times!!!
Matt

related questions