Sometimes there is a easier and more powerful way to do the process, but you’re just blind to thinking of it. The “Evaluate” function in lotusScript is one of those things, especially when your coding for long periods in just LotuScript. “Evaluate” lets you “Execute a Lotus software application macro.” ( i.e. a Lotus formula string ) and is usually of the form : “resultvariant = Evaluate ( macrostring [ , object ] )”.
One of the confusing things is when the optional “object” is needed. (And if needed, should it be a NotesDocument, a NotesDatabase or something else?) The default help really does not provide enough examples or hint at the power of Evalute.
There are several excellent resources for more examples and information.
One is a Notes Net article from 1998 (R4.5 days), Simplifying your LotusScript with the Evaluate statement, which is still very relevent, and has lots of examples, in addtion to a sample db demo the code (Note: the sample file in the sandbox is a zipped file with NO extension. give it a “.zip” extension when you download). One example is a dblook evalute which runs in about 1/4 of the time of a typical lotusscript GetAllDocumentsByKey and Loop Through (!!).
Tom Duff has a entry from 2004 which is hugly useful : Tips for Working with the LotusScript Evaluate Function.
One thing I do is use the vertical bar character | instead of the double quote ” character around the “macrostring”. (see my example below)
One example almost replaces the need for the code in my earlier Finding out if the current user has a given role, in Lotus Script SnTT – which itself uses a Evaluate(“@UserRoles”).
Dim Doc as NotesDocument
Dim ReaderAccessFieldContainsAdmin As Variant
Set Doc = 'set the document to that having a field called ReaderAccessField....
ReaderAccessFieldContainsAdmin = Evaluate(|@Contains(ReaderAccessField;"Admin")|, Doc)
If ReaderAccessFieldContainsAdmin(0) = 1 Then ' the field "ReaderAccessField" does contain the value "Admin"
..do something else...
or if you need the Comman Name of a the value stored in the field “MailServer”,
Dim servername as variant
servername = Evaluate(|@Name([CN];MailServer)|, Doc) ' the doc being a Person Doc in the NAb
( you could also do a “Evaluate(|@Name([CN];@userName)|, Doc)” )
also I’ve used :
Doc.CreatedDateTime = Evaluate(|@Now|)
any other good examples or Evaluate stories? Otherwise, go out there and do less work! 😉