Options

Calculate fields in one go.

mysamzamysamza Member Posts: 66
I am extending the Item Master table and page with 7 Integer type fields.

Let's call them;

Field1
Field2
Field3
Field4
Field1Calculated (Editable = False)
Field2Calculated (Editable = False)
Field3Calculated (Editable = False)
Field1Calculated will be the Value of Field1;

Field2Calculated will be the Value ("Field1" + "Field2") - "Field3"

Field3Calculated will be the Value (("Field1" + "Field2") - "Field3") - "Field4";


I tried writing the code on the OnValidate() in such a way

trigger OnValidate()
var
begin

"Field2Calculated" :=  ("Field1" + "Field2") - "Field3"
end;

However this seems to not work since I would want for any of the FieldX Value users changes, I would want to fire the calculation logics of all 3 FieldXCaclulated fields to update in the table respective changes.

How do I go about implementing this?

Thanks a ton in advance for the guidance.

Answers

  • Options
    vaprogvaprog Member Posts: 1,118
    If you really need these fields as fields in the table, I would create a function that calculates the values of all three calculated fields and add this function to each of the editable fields' OnValidate trigger.

    If you don't need the calculated fields in the table, just do your calculations on the Page and use global variables. Do your calculation in the OnAfterGetRecord and in the OnValidate trigger of Field1..4.
Sign In or Register to comment.