Use of SETAUTOCALCFIELDS Function in D365 BC:
(1) In this article, we will get to know the use of the SETAUTOCALCFIELDS function in AL programming in D365 BC. It is used for calculating the value of FLOWFIELDS. FlowFields are virtual fields. The values in these fields are not saved in the table. This means that you must use either the CALCFIELDS function or the SETAUTOCALCFIELDS function. It sets the FlowFields that you specify to be automatically calculated when the record is retrieved from the database.
|[OK :=] Record.SETAUTOCALCFIELDS([Field1,Field2, …])|
(3) Use and Improvement of SETAUTOCALCFIELDS as:
- It is used for calculating values of FlowFields.
- Improves performance by using the SETAUTOCALCFIELDS function before looping through records with FlowFields instead of calling the CALCFIELDS function on each record in the loop.
(4) Let’s take an example.
- SETAUTOCALCFIELDS for FlowFields: For calculating FlowFields follow the below image. Suppose we want to calculate and display the Item Inventory. Note but sure that the field nature should be FlowField, otherwise system shows an error while running the object. You can also use in Repeat until function for retrieving records from flowfields.
(5) For using this syntax, you must know about the “FlowFields” & “FlowFilters”. Patterns and use of SETAUTOCALCFIELDS function in BC D365, as shown.
- Calculating As On Inventory:
- Calculating Locationwise On Inventory:
- Calculating Date Range On Inventory:
- Calculating Multiple Flow Fields: