Simple Lotus Script for a Formula User

This is a silly question for a script user but I pretty much only know formula.

Given the code below, I need to add a line(s) that will set a number field in a document to the product of two other number fields in the same document “on change”. I have the below code “On Change”, can you tell me how the line “field1 = field2 * field3” should be coded?

Thanks so much, Paul

Sub Onchange(Source As Field)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument



???field1 = field2 * field3???



Call uidoc.Refresh

End Sub

Subject: Code

Call uidoc.FieldSetText(“Field1”, Cstr(Cint(uidoc.FieldGetText(“Field2”)) * Cint(uidoc.FieldGetText(“Field3”))))

This assumes the numbers are integers.

If they are Long or Double, you need to change Cint to Dlng or Cdbl.

Subject: Sweet!

That worked!!! Thanks so much, I really wish I new all of this better…

Take care, Paul

Subject: Could I ask for one more thing?

Sorry, I should have included this in my first request…

Using an “if / endif” branch, how do I compare a date field to a hard coded date. In other words:

if field4 is later then 4/17/2014

then Call uidoc.FieldSetText(“Field1”, Cstr(Cint(uidoc.FieldGetText(“Field2”)) * Cint(uidoc.FieldGetText(“Field3”))))

Thanks, Paul

Subject: One way…

One way to compare dates would be like this:

docdate = uidoc.FieldgetText(“Fieldname”)

If Cdat(docdate)>cdat(“04/17/2014”) Then

End If

You can also create NotesDateTime objects, but for something simple like this, you don’t need that.

Subject: Perfect!!!

Perfect, it’s seems so easy when you know what you are doing!

Thanks again, Paul