Use of SETAUTOCALCFIELDS Function in D365 BC

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.

(2) Syntax:

[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 As On Inventory- SETAUTOCALCFIELDS
  • Calculating Locationwise On Inventory:
Calculating Locationwise On Inventory- SETAUTOCALCFIELDS
  • Calculating Date Range On Inventory:
Calculating Date Range On Inventory- SETAUTOCALCFIELDS
  • Calculating Multiple Flow Fields:
Calculating Multiple Flow Fields- SETAUTOCALCFIELDS

Set Default Column in Freeze Pane in D365 BC
Auto creation of Item while entering Item Description in Sales Line in D365 BC
How to Enable Multi-Factor Authentication in D365 BC Online
Types and Setup of Voucher in D365 BC for Indian Localization
How to Attach and Download Files and Images in Documents in D365 BC

Leave a Reply