Understanding immutable keys

With the Dynamics 365 Business Central wave 2 release, all tables now have a (unique) immutable key (a GUID field) that can be used for integration scenarios and for replacing the old RECORDID property. This new field is called SystemId and it's a GUID data type field that specifies a unique, immutable (read-only) identifier for records in a table.

The new SystemId field (identified with the field number 2000000000 on every table object) has the following characteristics:

  • It has a value for every record in a table.
  • You can assign a value at insert time; otherwise, the platform automatically assigns one.
  • Once SystemId has been set, it cannot be changed.
  • There is always a unique secondary key in the SystemId field.

As a platform rule, modifying SystemId of an existing record is not allowed. The INSERT function now has a new override:

Record.Insert([RunTrigger: Boolean[, InsertWithSystemId: Boolean]])

SystemId can be manually specified when inserting a new record, as in the following example:

myRec.SystemId := '{B6667654-F4B2-B945-8567-006DD6B6775E}';
myRec.Insert(true,true);

You can now use the GetBySystemId function to retrieve a record via its SystemId, as in the following example:

var
Customer: Record Customer;
Text000: Label 'Customer was found.';
begin
if Customer.GetBySystemId('{B6667654-F4B2-B945-8567-006DD6B6775E}') then
Message(Text000);
end;

You can also set table relations by using the new SystemId field, as in the following code:

field(1; EntryID; GUID)
{
DataClassification = CustomerContent;
TableRelation = Item.SystemId;
}

The Integration Record table before version 15 has GUIDs for records. The upgrade process to Dynamics 365 Business Central version 15 will use these values to initialize the new SystemId field. In the future, the Integration Record table will be declared obsolete. The SystemID field is also useful on API pages.

In the next section, we'll see how to handle files with AL in an software as a service (SaaS) environment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.59.231