FlowFields are the fields which are used only to display the result of a calculation based on the “calcFormula” property. They are not the physical fields, as they do not store any value in the database. Interestingly, the values in the flowFields exists only at runtime. By default, the flowfields are initialized to 0. There are seven (7) types of flowFields, namely, sum, average, exist, count, min, max and lookup.
We define a flowField by defining the fieldClass property as FlowField and giving the calcFormula property as per our requirement.
Below, we have defined a flowField, “Name”, which is used to display the name of the customer. Here we have created the flowField of type “lookup”.
When the FlowField is the direct source of expression of a control on page, then FlowField is updated automatically based on calcFormula property when the page is displayed.
Now, if a flowfield is initialized to 0, how do we update the value of that flowfield? The answer to this question is using CalcFields Method.
Let us learn about the calcFields method.
This method is used to update the value of a flowfield. As we know that FlowFields have calcFormula property. CalcFields use the current filters and perform the calculations defined in the calcFormula property and updates the value of the flowField.
Let us make use of this calcFields in our code,
- We will define a procedure which shows us balance (flowField) of a customer.
- Firstly, we will use Record. Get () method to retrieve the record from customer table, based on the primary key field.
- Now the balance is a flowField, If we don’t update it (without using calcFields) then it will show the balance as 0.
- So, we will use the calcFields method for updating the value of this flowField.
- Now Balance has some value to display, based on calcFormula.
- We will now use message () to display the Balance.
For more details kindly visit our linkedin page:
By Harshit. T.