PostRecalc

I’ve been having problems with a specific issue. I am trying to set a default value from a computed field using the postrecalc event hoping it will help a inputvalidation issue.I have the following formula in a postrecalc event:

Sub Postrecalc(Source As Notesuidocument)

Dim location As Integer

location = source.FieldGetText( "FieldValue4" )

Call source.FieldSetText( "FieldValue5", FieldValue4 )

End Sub

I need to set the field using Integers and I realize FieldSetText won’t work because that looks for a string. My brain seems to be frozen because I can’t figure out how to set the field as an Integer.

Can anybody help?

Thanks!

Subject: PostRecalc

The form has to be refreshed to the PostRecalc to work, user chooses View - Refresh or presses F9.

You need to refresh, but don’t want the user to do anthing, try this: In fieldvalue5 put a script to refresh the current document whenever the user moves the cursor out of a particular field.

Sub Exiting(Source As Field)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Call uidoc.Refresh

End Sub

You should then be able to continue with the Input Validation.

Subject: RE: PostRecalc

I tried this prior to posting for help and it does not work.

All this code happens in a dialog box so when I hit the button to call the dialog box using the Sub Exiting code, it fails validation right away without even getting to the fields. I thought the postrecalc would be the best option because the dialog box is alreay refreshing the fields.

Subject: Okay! But have to ask…

Why is it all in a dialog box? I’m not understanding something, I’m sure.

Subject: RE: Okay! But have to ask…

It’s just the way the form is created because there are other fields as well. Do you know how to do the postrecalc from my original post? Setting an integer field?

Subject: I’ll try it.

Subject: It worked, but I had to add…

@IsDocBeingSaved to the input validation formula.

@If(@IsDocBeingSaved & Field4 != “” & Field0 = “SS Mileage” & Field5 != Field4 & Field6 = “”; @Failure(“You must enter a reason/description for the non-default mileage amount”);@Success)

Subject: RE: It worked, but I had to add…

It didn’t work for me. It saved regardless of what is entered in Field5. I’m never prompted if Field6 is blank…

Subject: Here’s my test:

field0, computed text = "SS Mileage"field1, computed number = 2

field4, computed, number = Field1 * 2 with

field5, editable number with the following in the exiting event:

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Call uidoc.Refresh

field6, editable text with the following in the input validation:

@If(@IsDocBeingSaved & Field4 != “” & Field0 = “SS Mileage” & Field5 != Field4 & Field6 = “”; @Failure(“You must enter a reason/description for the non-default mileage amount”);@Success)

Sorry I can’t resolve your problem!

Subject: PostRecalc

Hello Laura,

First, if you want to set integer values, try using the backend rather than the front end.

In script:

Dim doc as NotesDocument

Set doc = source.Document

doc.FieldValue5 = doc.FieldValue4

This will work with any format and will preserve your format.

Second, you can use this kind of formula to insure your default value in a computed field:

@If (@ThisValue = “” ; 0 ; @ThisValue)

This will make sure the value is a zero (an integer) - for instance! - when nothing was present in the field; otherwise it just compute to itself, which is great when you will modify it later with a dialogbox or with some sort of script.

Third, why do you want to set the field with the postrecalc, exactly?

HTH

Nicolas Abesdris

Quintessence e-solutions Inc.

Subject: RE: PostRecalc

The formula you gave for PostRecalc works by giving me a default value in an editable field (from the computed field), but it doesn’t let me change it. How do I do that? My objective is to have a default value in a field that is called from a computed field because it can change based on a lookup from another field. The user needs to have the ability to change that default if they want, but now that won’t work, it just reverts to the original default. Is there another workaround?

Subject: RE: PostRecalc

You say: "My objective is to have a default value in a field that is called from a computed field because it can change based on a lookup from another field. "

…

Aww… I am still confused in what exactly you are trying to do.

Let’s pick an exemple?

Let’s say you got

Field A: editable

Field B: computed lookup based on what?

Field C: computed from what formula?

Give me a precise exemple of what you need, and i’ll see if I can tell you how to do it.

:slight_smile:

Cheers

Nicolas Abesdris

Quintessence e-solutions Inc.