With the release of Business Central Wave 2 2020 the partial records capability is available.
SetLoadFields is an amazing feature of business central wave 2 2020.advantage of SetLoadFields is to make execution of code faster and give more performance.
following methods available in business central To accommodate partial records.
|SetLoadFields||Specifies a set of fields to be initially loaded when the record is retrieved from its data source.|
|AddLoadFields||Adds fields to the current set of fields to be initially loaded when the record is retrieved from its data source.|
|AreFieldsLoaded||Checks whether the specified fields are all initially loaded.|
|LoadFields||Accesses the table’s corresponding data source to load the specified fields.|
We are used to loads fields together when necessary to retrieve record from table, I think it will select record from table. It will take little bit more time . SetLoadFields fuction reduce this time and I think it retrieve field from table . so, performance improve.
Let’s see with example, we want to calculate sum of Unit Price of filtered items and message total amount.
If you see SetLoadFields is call before data fetching operation starts. This will determine which fields needed for Find Set Call.
Publish it and Open Business central -Item List page
Try this code with SetLoadFields() and Without SetLoadFields.
I recommend to Use this feature while fetching data from table . Not for Insert (), Modify () and Delete() Operation.
There are also some other functions available to partial records(AddLoadFields, LoadFields,AreFieldsLoaded) But I think SetLoadFields is Important One.
Thanks for reading.