Rename or Change the value of Primary Key in BC D365:
(1) Introduction: When you want to change the value of a primary key, then RENAME method is used.
(2) Syntax:
[Ok := ] Record.Rename(Value1: Any [, Value2: Any,…]) |
(3) Let’s take two examples one is to change Document No. of Sales Order Document & the second is to change Document No. of Sales Quote as shown.

(4) Note: Do not disturb the sequence of the primary keys. Suppose in the above example, document no. is changed but document type is also defined with the old value.
DELETE and DELETEALL in D365 BC How to define Custom Object Range in AL in D365 BC Usage of TRANSFERFIELDS in D365 BC How to Fix WORK DATE issue in D365 BC AL Control Statements– Microsoft Docs |