How to get the value of a formula field in script?

For an application i should get the value of the $FilterFormula field in the calendar profile in lotus script. But it´s everytime empty with all methods and properties in ls:

formula = doc.GetItemValue(“$filterformula”)

formula = item.values

formula = item.text

With Ytria and Notespeek i can see the value, but how to get it programatically?

THX!

Subject: How to get the value of a formula field in script?

I have used extended syntax, like this:

doc.~$filterformula

Regards,

Don

Subject: RE: How to get the value of a formula field in script?

Thank you, but the messagebox leaves empty :o(

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Set db = s.CurrentDatabase

Set doc = db.GetProfileDocument(“CalendarProfile”)

Msgbox doc.~$filterformula

Subject: RE: How to get the value of a formula field in script?

Try Evaluate({ @Text($filterformula) }, doc) ?

Subject: RE: How to get the value of a formula field in script?

Did you try

Msgbox doc.~$filterformula(0) ?

Subject: RE: How to get the value of a formula field in script?

This code returns the error “Variant does not contain a container”.

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim item As NotesItem



Set db = s.CurrentDatabase

Set doc = db.GetProfileDocument("CalendarProfile")

Msgbox doc.~$filterformula(0)

Subject: RE: How to get the value of a formula field in script?

Try this way:

Msgbox trim$(doc.~$filterformula(0))

Subject: How to get the value of a formula field in script?

As far as I know, if you try to access a Notes Item of type Formula, using the backend classes, to get to its value, all you will get is an empty string.

To get to the actual value you will have to use the frontend classes. The below method is not pretty, but will work. You will have to, first, create a Form and, then, create the $FilterFormula fields. Next, using LotusScript, you get a handle to the calendar profile, copy all the items to a new document, render the document using the form, launch the document in the UI and then use FieldGetText. Now, depending on what your end goal is, the below method may or may not help you at all.

--------Dim s As New NotesSession

--------Dim db As NotesDatabase

--------Dim doc As NotesDocument

--------Dim wSpace As New NotesUIWorkspace

--------Dim uiDoc As NotesUIDocument

--------Set db = s.CurrentDatabase

--------Set doc = db.GetProfileDocument(“CalendarProfile”)

--------Dim nDoc As New NotesDocument( db )

--------nDoc.Form = “tmp”

--------Call doc.CopyAllItems( nDoc )

--------Set uiDoc = wSpace.EditDocument( False, nDoc )

--------Dim textValue As String

--------textValue = uiDoc.FieldGetText( “$FilterFormula_0” )

--------Call uiDoc.Close

--------Msgbox textValue

Subject: RE: How to get the value of a formula field in script?

Thank you for your help! This way works fine.One question again: If i would write a formula back can i write a string value to the field and make a computewithform? Does this work?

THX!!!

Subject: RE: How to get the value of a formula field in script?

Yes, you can. However, the string that you are adding to the field has to evaluate to a valid formula. Otherwise, the Lotus Notes client will “scream” back at you.