AutoIncrement fields are not supported in temporary tables
Properties
PC0002
Error
Design
Code Fix
Ignore Obsolete
AutoIncrement relies on SQL Server to generate the next value when inserting records. Temporary tables with TableType = Temporary only exist in memory on the Business Central server — they are never created on SQL Server. When code inserts a record into such a table, the runtime cannot obtain the next auto-increment value and the insert fails.
The AutoIncrement property does not work with Dynamics 365 Business Central temporary tables.
— AutoIncrement Property on Microsoft Learn
Remove the AutoIncrement property and manage the field value in code.
Example
table 50100 "Tracking Entry"
{
TableType = Temporary;
fields
{
field(1; "Entry No."; Integer)
{
AutoIncrement = true; // AutoIncrement fields are not supported in temporary tables [PC0002]
}
}
}Remove the property and assign the field value before inserting:
table 50100 "Tracking Entry"
{
TableType = Temporary;
fields
{
field(1; "Entry No."; Integer)
{
}
}
}