How to Use SetLoadFields in Business Central for performance

With the release of Business Central Wave 1 2020 the partial records capability is available.

The partial records capability is allows for loading a subset of normal table fields when accessing the data source based on SQL.

To access the data source we use GET ,FIND NEXT. When we use these methods then runtime it load all fields and will hamper the performance while fetching the records.

Now from business central wave 2 2020 we can use ‘Partial records’ capability.

To accommodate partial records following methods available in business central. These methods are avaaible on RecordRef and Record datatype in AL. These methods are loaded in two groups i.e. Subsequent loads and Current load

MethodDescription
SetLoadFieldsSpecifies a set of fields to be initially loaded when the record is retrieved from its data source.
AddLoadFieldsAdds fields to the current set of fields to be initially loaded when the record is retrieved from its data source.
AreFieldsLoadedChecks whether the specified fields are all initially loaded.
LoadFieldsAccesses the table’s corresponding data source to load the specified fields.

Lets See few examples of these methods

Following example is for summation of Quantity fields from Item Ledger Entry .In this we would like to make calculation of only Quantity fields and not require the others fields to be loaded.

If you see SetLoadFields is call before data fetching operation starts. This will determine which fields needed for Find Set Call.

Advantage of this is that it gives you ability to load only those fields which are required to perform the operation which will make execution of code faster and give more performance. This feature is recommended to use while fetching the records and not for Insert,Modify or Delete operation.

Using the above method we added the required fields but what will happen to other fields which hasn’t been loaded .In such cases platform does an implicit GET and loads the missing fields, called as JIT Loading (Just in Time).

When JIT loading occurs, another access to the data source is required. These operations tend to be faster because they’re GET calls. GET calls can often be served by the server’s data cache or become clustered index seeks on the database.

Iterating over records in the database, enumerator is created based on selected fields and row is fetched when NEXT is called. but certain operations will not follow enumerator like if we passing a record by value and not by VAR .This operation actually creates new copy of the record and original records and copy of the record not share the filters ,selected field for loading. That means to access unloaded fields it need to trigger JIT load and but it will not update enumerator which means for future iterations also require JIT load.

To overcome such situations we can do following

  1. Pass the record reference using VAR.
  2. Call AddLoadFields on the original records before passing by value.
  3. Use SetLoadFields before calling FIND,GET,NEXT.

Hope this will help you to understand for partial records and stay tuned for more updates.

For more updates you can follow my blog on following channels.

Use of implicit ‘with’ will be removed in the future :-Business Central

Though above warning was informed by MS long time back but it has introduced in latest version of AL.

With the update of new version of AL extension this warning is populated in AL code.

Once you update above AL language version then you will find below warning

Now this warning will become error in near future that means we need to correct it anyhow . If your app contain more than 100 pages then it will be too much efforts to make it manually and tedious task.

To make it superfast work we have one extension available in marketplace which will help you to resolve it within seconds.

Once you install the extension then Press ‘F1’ and run following command

‘Fix Implicit with usages’

Just have look at the following file

Now run above command and relax as it will fix the warning in all pages.

Result of the file after running command

It will fix the all warning in all the files.

Hope this will help you

Stay tuned for more update

The ID Range ‘[50000..99999] is not valid : Business Central

Today morning I update AL extension with the latest version as below

After update I found following issue for Per Tenant app and was not able to find any clue for this issue

To resolve the issue decided to roll back to latest update and it works fine but it is not giving the latest updates for AL

Then I decided to ask our beloved community

MVP https://twitter.com/ajkauffmann gave the solution to resolve this

Actually I was doing mistake in App Source Analyzer that I enabled both AppsourceCop and PerTenantExtensionCop for PerTenant App which was not correct

This is actually not correct because we need enable code analyzer like

If developing App within Certified App range (70M) then enable AppsoureCop and if developing app for Tenant then enable PerTenantExtensionCop.

This resolve my issue.

Hope this will help you..

You can go through the twitter thread.

Business Central Wave 2 2020 Released

With the new dawn of 1st October Microsoft released Business Central Wave 2 2020.

This version is available for following

  1. W1 Version
  2. 21 Localized version
  3. India localization in Preview

The product DVD will be downloaded from following URL

Business Central Wave 2 2020

Few features of Business Central you can visit this link

Business Central Wave 2 2020 Features

Stay tuned for more detail

Cumulative Update for Business Central September 2020

Cumulative Update includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics Business Central

MS Dynamics Business Central 2020 Wave 1 (BC16) :- CU 16.5

MS Dynamics 365 Business Central 2019 Release Wave 2(15.10) :- CU 15.10

Business Central Spring Release (BC16) :- CU16

Warning

Before you install a cumulative update in a production environment, take the following precautions:

  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.

Stay tuned for more updates…

Cumulative Update for Business Central August 2020

Cumulative Update includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics Business Central

MS Dynamics Business Central 2020 Wave 1 (BC16) :- CU 16.4

MS Dynamics 365 Business Central 2019 Release Wave 2(15.9) :- CU 15.9

Business Central Spring Release (BC14) :- CU15

Warning

Before you install a cumulative update in a production environment, take the following precautions:

  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.

Stay tuned for more updates…

How to Create Custom Event in Business Central

Looking at the subject there are lot of blogs available but I am writing this based on one of the request from my colleague.

Everybody aware of that whenever you developed an app it need to be extensible and if anybody would like to add or modify any field or additional routing we need to have events which can extend the base functionality.

Step 1 :- Simple Quick action to add event in Business Central

Next step will be we can subscribe the event and add you own code.

It is so simple to add custom event in AL and allow other to extend your functionality.

Hope this will help you.

Stay tuned for more updates.

Cumulative Update for Business Central July 2020

Cumulative Update includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics Business Central

MS Dynamics Business Central 2020 Wave 1 (BC16) :- CU 16.3

MS Dynamics 365 Business Central 2019 Release Wave 2(15.8) :- CU 15.8

Business Central Spring Release (BC14) :- CU14

Warning

Before you install a cumulative update in a production environment, take the following precautions:

  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.

Stay tuned for more updates…

Business Central Wave 2 2020 Upcoming Features

By writing this I feel that clock is running faster and till the time we are utilizing the features of Wave 1 2020 more new features are planned and about to release in upcoming version Wave 2 2020.

There are plenty of features are planned for Wave 2 2020 but will list here what are the features I am looking for.

  1. Database access intent changed to read-only for frequently used reports As business required faster access to the information so to speed up default database access change to Read-only.
  2. Notify users of high-risk changes in selected setup fields :- This features means we can make list of fields from master table and get notified when someone changes.
  3. Business Central in Microsoft Teams :-Integrate Microsoft team with Business Central.
  4. Page Inspector supports temporary tables :- With this update, the inspection pane now displays valuable record information also for pages that are implemented to use temporary tables. Information about the current record is displayed in a consistent way and is not different from inspecting pages that use physical source tables.
  5. Data audit system fields are added to every table :- Four New Field will be added in every tables to track the transactions log.
    1. SystemLastModifiedOn
    2. SystemLastModifiedBy
    3. SystemCreatedBy
    4. SystemCreatedOn
  6. Attach to user session when debugging in sandbox :-Currently, when you debug with the Visual Studio Code AL debugger, you cannot attach to a user session, making it much harder to troubleshoot issues that are dependent on users and user permissions. This feature enables attaching to an active user session on the sandbox.
  7. Debug extension installation and upgrade code :- It is currently not possible to debug extension install or upgrade code by just adding breakpoints and deploying a new application. Instead, some workaround is required to manually trigger the install and upgrade code, possibly commenting out upgrade tags and so on, making it tedious to properly test install and upgrade during development, as well as to troubleshoot issues.

For More information on Planned features please check this link

What New and Planned for Dynamics 365 Business Central

Hope this will help you

Stay tuned for more updates.

Cumulative Update Summary May 2020-Business Central

Cumulative Update includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics Business Central

Business Central 2019 Spring Update CU 12 :- BC 14

Business Central 2019 Fall Release Wave 2 :- BC2019Wave2

Warning

Before you install a cumulative update in a production environment, take the following precautions:

  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.

Stay tuned for more updates…