{"title":"FieldRef.CalcField() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/fieldref/fieldref-calcfield-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/fieldref/fieldref-calcfield-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/fieldref/fieldref-calcfield-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Updates FlowFields in a record.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":92,"chars":51},{"level":2,"title":"Parameters","slug":"parameters","at":143,"chars":97},{"level":2,"title":"Return Value","slug":"return-value","at":240,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":478,"chars":754},{"level":2,"title":"Example","slug":"example","at":1232,"chars":1049},{"level":2,"title":"Related information","slug":"related-information","at":2281,"chars":219}],"text":"> Version: _Available or changed with runtime version 1.0._\nUpdates FlowFields in a record.\n## Syntax\n```al\n[Ok := ]  FieldRef.CalcField()\n```\n## Parameters\nFieldRef\nType: fieldref-data-type\nAn instance of the fieldref-data-type data type.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nFlowFields 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 ../recordref/recordref-find-method and ../recordref/recordref-next-method 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.\nWhen 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\\). See BLOB Data Type<../library>.\nThis method is similar to the ../record/record-calcfields-method method.\n## Example\nThe following example opens table 18 \\(Customer\\) as a RecordRef variable that is named CustRecordref. The ../recordref/recordref-find-method selects the first record in the table and then loops through all the records until no records could be found. For each record, the ../recordref/recordref-field-method 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.\n```al\nvar\n    CustRecordref: RecordRef;\n    MyFieldRef: FieldRef;\n    Count: Integer;\n    Text000: Label '%1: \\\\Balance Due: %2.';\nbegin\n    Count := 0;\n    CustRecordref.Open(18);\n    if CustRecordref.Find('-') then\n      repeat\n        MyFieldRef := CustRecordref.Field(66);\n        MyFieldRef.CalcField;\n        Message(Text000, CustRecordref.RecordId, MyFieldRef);\n        Count := Count + 1;\n      until CustRecordref.Next = 0;\nend;\n```\n## Related information\nfieldref-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\n../../../administration/optimize-sql-al-database-methods-and-performance-on-server"}