Hi, Readers.
Today I would like to share another mini tip about Business Central, how to check whether a field is a Flowfield via AL.
FlowFields display the result of the calculation described in the CalcFormula Property. For example, the Inventory field in the Item table shows the current inventory of the item and is calculated as the sum of the Quantity fields for all Item Ledger Entries in this item.

Source Code in Item table: FieldClass Property and CalcFormula Property

More details about FlowFields in Business Central: FlowFields (Sum, Average, Exist, Count, Min, Max, Lookup)
Recently I was asked an interesting question, is there any way to check if a field is a FlowField via AL. So in this post, I briefly introduce two ways.
Item (27) -> Inventory (68, Decimal)

1. Using FieldRef.Class() Method
FieldRef.Class() Method: Gets the value of the FieldClass Property of the field that is currently selected. This method returns an error if no field is selected.
FieldClass Property: Sets the class of the field.
Value | Available or changed with | Description |
---|---|---|
Normal | runtime version 1.0 | A data entry field. |
FlowField | runtime version 1.0 | A calculated field. |
FlowFilter | runtime version 1.0 | To compute the results of FlowFields. |
We can simply do the following example. (If condition is just for reference)


Source code:
pageextension 50110 ZYItemListExt extends "Item List"
{
trigger OnOpenPage()
var
RecRef: RecordRef;
FldRef: FieldRef;
Msg: Label 'Field ''%1'' is a %2';
begin
RecRef.Open(Database::Item);
FldRef := RecRef.Field(68);
if FldRef.Class = FieldClass::FlowField then
Message(Msg, FldRef.Caption, FldRef.Class);
end;
}
2. Using Field Virtual Table (table 2000000041 “Field”)
The Field virtual table (ID 2000000041) contains information about fields in database tables. And it contains the Class field.
Field | Description |
---|---|
TableNo | The ID number for the table. |
No. | The number assigned to the field. |
Table Name | The name of the table. |
FieldName | The name of the field. |
Type | The data type assigned to the field, for example, decimal. |
Class | The class of the field, for example, FlowField. |


We can do the same thing as above. (If condition is just for reference)


Source code:
pageextension 50110 ZYItemListExt extends "Item List"
{
trigger OnOpenPage()
var
FieldRec: Record Field;
Msg: Label 'Field ''%1'' is a %2';
begin
if FieldRec.Get(Database::Item, 68) then
if FieldRec.Class = FieldRec.Class::FlowField then
Message(Msg, FieldRec."Field Caption", FieldRec.Class);
end;
}
Very simple, give it a try!!!😁
PS:
1. What happens if users don’t have permission to read the table set in a FlowField?
2. How to export all fields in all tables
End
Hope this will help.
Thanks for your reading.
ZHU
コメント