Business Central 2022 wave 2 (BC21) new features: Access database row version from AL code – (field) SystemRowVersion: BigInteger

Dynamics 365 Business Central

Hi, Readers.
The preview environment for Dynamics 365 Business Central 2022 release wave 2 (BC21) is available. Learn more: Link.

I will continue to test and share some new features that I hope will be helpful.

Access database row version from AL code:

Business value:

Developers and administrators can get insights into the version of database rows. They can use this to make integration and data analytics scenarios faster by only querying the latest updated data.

Feature details

The database for a Business Central environment tracks a global number called rowversion across all tables. With this feature, the Business Central platform makes this data accessible from AL code. Developers can then add the rowversion field to indexes or use it to query most recent changes to the database.–developers-use-database-rowversion-al

Data audit system fields is one of new features in Business Central 2020 release wave 2 (BC17). Microsoft added four new system fields to all tables.

Business value:
This gives developers an easy and performant way to program against historical data, such as writing AL queries that return changed data since some specified point in time.

Feature details:
Four new system fields are added to all tables:

Data audit system fields are added to every table – Dynamics 365 Release Plan | Microsoft Docs

This is very useful. And with this wave, Microsoft has added a new field to all tables, RowVersion field.

As you might know, each database has a counter that is incremented for each insert or update operation that is performed on a table that contains a rowversion column within the database. This counter is the database rowversion.

Let’s see two examples.

table 348 Dimension:

table 3 “Payment Terms”:

As with the Data audit system fields, it is not added directly to the table.

But different from the Data audit system fields, we can’t find it in the system table (Field 2000000041) either. (Field table also has RowVersion field, and the value is 1.)

We also can’t find it in Designer.

So how to use it?

As mentioned in the release plan, we can easily access it from AL code.

For example,

Row Version: 211831

In Customer table.

A table can have only one rowversion column. Every time that a row with a rowversion column is modified or inserted, the incremented database rowversion value is inserted in the rowversion column.

Test Video:

Give it a try!!!😁


Hope this will help.

Thanks for reading.