I have a form with a field ItemNumber
that has a validation forumla that ensures a value is entered.
In lotusscript i create a new document with that form, then depending on the value of a different computed field ItemProductFamilyType
(computed based on a field of another doc) i might want to populate ItemNumber
.
The issue i have is that if i look at the value of ItemProductFamilyType
it's blank, because it's not yet been computed. It'll only have a value once a field is updated, then it's the document refreshed/re-computed.
I'm trying to use ComputeWithForm
for this (with the raiseError
parameter being a 1 or 0), however because of validation formulas on other fields it's not letting me.
So, how can i get computed fields to update their value without checking/erroring on validation formulas?
Try adding a validation control field. So, add a field called "runValidation". It's computed for display, as it's only required for UI form events handling. It's formula is straight forward
@ThisValue or runValidation
In the QueryRecalc event or whenever you want to set the value for ItemProductFamilyType set it to "1".
Sub Queryrecalc(Source As Notesuidocument, Continue As Variant)
On Error Goto errHandle
Dim doc As notesDocument
Set doc = source.Document
' go populate your fields like ItemProductFamilyType
doc.runValidation = "1"
Exit Sub
errHandle:
Messagebox Lsi_info(2) + " : " + Str(Err) + " - " + Error(Err) + ", at line " + Str(Erl)
Exit Sub
End Sub
The same idea works in the translation formula of ItemProductFamilyType
Field runValidation := "1";
@thisValue;
In the validation formula for ItemNumber include the "runValidation" field to manage when the field should validate.
@if(runValidation="1";@if(@trim(@ThisValue)="";@Failure("Enter value");@Success);@Success)
You should now be able safely call a Source.Refresh
method without inadvertently triggering validation rules until the data is ready.