FieldRef.CalcField() Method

Version: Available or changed with runtime version 1.0.

Updates FlowFields in a record.

Syntax

[Ok := ]  FieldRef.CalcField()

Parameters

FieldRef
 Type: FieldRef
An instance of the FieldRef data type.

Return Value

[Optional] Ok
 Type: Boolean
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

FlowFields are virtual fields. The values in these fields are not saved in the table. This means that you must use the CalcFields method to update them. For example, if you retrieve a record using the Find Method (RecordRef) and Next Method (RecordRef) methods, the FlowFields in those records are set to zero (0). Then, you can call FieldRef.CalcField, to calculate the value in one of the FlowFields.

When a FlowField is a direct source expression of a control on a page or a report, the calculation is automatically performed. You can also use the CALCFieldS method to calculate binary large objects (BLOBs). For more information, see BLOB Data Type.

This method is similar to the CalcFields Method (Record) method.

Example

The following example opens table 18 (Customer) as a RecordRef variable that is named CustRecordref. The Find Method (RecordRef) selects the first record in the table and then loops through all the records until no records could be found. For each record, the Field Method (RecordRef) creates a FieldRef variable that is named MyFieldref for the Balance Due field (field 66), which is a flow field. The CalcField method is called to update the field before the customer ID and the balance due are displayed. Otherwise, the balance due for every record will be set to 0.

var
    CustRecordref: RecordRef;
    MyFieldRef: FieldRef;
    Count: Integer;
    Text000: Label '%1: \\Balance Due: %2.';
begin
    Count := 0;  
    CustRecordref.Open(18);  
    if CustRecordref.Find('-') then  
      repeat  
        MyFieldRef := CustRecordref.Field(66);  
        MyFieldRef.CalcField;  
        Message(Text000, CustRecordref.RecordId, MyFieldRef);  
        Count := Count + 1;  
      until CustRecordref.Next = 0;  
end;

See Also

FieldRef Data Type
Get Started with AL
Developing Extensions
AL Database Methods and Performance on SQL Server