
In D365FO you can rename the primary key of a table record with the Rename function.
This allows you to rename the primary key of any record and ensures data consistency
It can be accessed from the Record information form (shown in the following screenshot), which can be opened by selecting Record info from the right-click menu on any record


You can obtain the same result via X++ code following this example
class LoadIdRename
{
public static void main(Args _args)
{
Loadtable loadTable;
ttsBegin;
select firstOnly loadTable
where loadTable.LoadId == 'OldValue';
if (loadTable)
{
loadTable.LoadId = 'NewValue';
loadTable.renamePrimaryKey();
}
ttsCommit;
}
}
Leave a comment