# RecordRef.Rename(Any [, Any,...]) Method
> Version: _Available or changed with runtime version 1.0._
Changes the value of a primary key in a table.
## Syntax
```al
[Ok := ]  RecordRef.Rename(Value1: Any [, Value2: Any,...])
```
## Parameters
RecordRef
Type: recordref-data-type
An instance of the recordref-data-type data type.
Value1
Type: ../any/any-data-type
The new values for the primary key.
*[Optional] Value2*
Type: ../any/any-data-type
The new values for the primary key.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Remarks
You cannot rename some tables. Examples of the types of tables that you cannot rename are:
 Tables in which the user is not allowed to rename the Document No. for legal or business reasons.
 Tables in which an Option data type field, such as Document Type, is part of the primary key.
Some examples of tables that you cannot rename are:
 Table 36, Sales Header
 Table 38, Purchase Header
 Table 5405, Production Order
 Table 5766, Warehouse Activity Header
If an end-user modifies a record between the time that another end-user or another process reads the record and modifies it, then the second user must refresh the value of the record variable before editing the record. Otherwise, the end-user receives the following run-time error:
Another user has modified the record for this \<Table Name> after you retrieved it from the database.
Enter your changes again in the updated window, or start the interrupted activity again.
In earlier versions of Dynamics 365, certain situations allowed code that an end-user runs to modify a record after a newer version of the record was written and committed to the database. This would overwrite the newer changes. However, in Dynamics 365 Business Central, we have restricted the recordref-modify-method, Rename Method \(RecordRef\), and recordref-delete-method so that the end-user receives the following run-time error in these certain situations:
Unable to change an earlier version of the \<Table Name> record. The record should be read from the database again. This is a programming error.
You must design your application so that you use the most up-to-date version of the record for modifications to the database. You use the recordref-get-method to refresh the record with the latest version.
## Example
This example shows how to change the value of the primary key of a Record variable, and how to change the value of the primary key of a RecordRef variable.
```al
var
    CustRecRef: RecordRef;
    NewNo1: Code;
    NewNo2: Code;
    result: Boolean;
    CustomerRec: Record Customer;
begin
    CustomerRec.Get('0112121');
    NewNo1 := ‘9999999’;
    NewNo2 := ‘8888888’;
    Message('Customer name: %1; Customer number: %2',CustomerRec.Name, CustomerRec."No.");
    result := CustomerRec.Rename(NewNo1);
    if result then
      Message('After rename - Customer name: %1; Customer number: %2',CustomerRec.Name, CustomerRec."No.")
    else
      Message('No rename.');
    CustRecRef.GetTable(CustomerRec);
    result := CustRecRef.Rename(NewNo2);
    if result then begin
      CustomerRec.Get(NewNo2);
      Message('After rename 2 - Customer name: %1; Customer number: %2',CustomerRec.Name, CustomerRec."No.")
    end else
      Message('No rename.');
end;
```
If a record with No. 0112121 is found, and if the renames are successful, then the following messages are displayed:
Customer name: Spotsmeyer's Furnishings; Customer number: 0112121
After rename - Customer name: Spotsmeyer's Furnishings; Customer number: 9999999
After rename 2 - Customer name: Spotsmeyer's Furnishings; Customer number: 8888888
## Related information
recordref-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-rename-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-rename-method/
