{"title":"Record.Rename(Any [, Any,...]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/record/record-rename-method/","by":"JOP-AL","license":"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/record/record-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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-rename-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Changes the value of a primary key in a table.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Record.Rename(Any [, Any,...]) Method","slug":"recordrenameany-any-method","at":0,"chars":4070},{"level":2,"title":"Syntax","slug":"syntax","at":147,"chars":77},{"level":2,"title":"Parameters","slug":"parameters","at":224,"chars":172},{"level":2,"title":"Return Value","slug":"return-value","at":396,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":634,"chars":1738},{"level":2,"title":"Example 1","slug":"example-1","at":2372,"chars":102},{"level":2,"title":"Example 2","slug":"example-2","at":2474,"chars":1462},{"level":2,"title":"Related information","slug":"related-information","at":3936,"chars":134}],"text":"# Record.Rename(Any [, Any,...]) Method\n> Version: _Available or changed with runtime version 1.0._\nChanges the value of a primary key in a table.\n## Syntax\n```al\n[Ok := ]  Record.Rename(Value1: Any [, Value2: Any,...])\n```\n## Parameters\nRecord\nType: record-data-type\nAn instance of the record-data-type data type.\nValue1\nType: ../any/any-data-type\n*[Optional] Value2*\nType: ../any/any-data-type\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nUse the Rename method, for example, if you use the customer's telephone number as the customer number. You can use this method to change the customer number in case the telephone number changes.\nCertain tables you cannot rename, for example:\n Tables in which the user cannot rename the Document No. field for legal or business reasons.\n Tables in which an Option data type field, such as Document Type, is part of the primary key.\nExamples of tables that you cannot rename are:\n Table 36, Sales Header\n Table 38, Purchase Header\n Table 5405, Production Order\n Table 5766, Warehouse Activity Header\nIf 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:\n`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.`\nYou 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 record-get-method to refresh the record with the latest version. The second example illustrates this situation.\nWhen a record is renamed, the change is written and committed to the database without calling the ../../triggers-auto/table/devenv-onmodify-table-trigger. This is done because renaming a record changes the primary key and updates the primary key value in all related tables. Therefore, you should use the Rename method and the Record.Modify([Boolean]) Method<record-modify-method> on a record separately.\n## Example 1\n```al\nvar\n    CustRec    Record Customer\n\nCustRec.Get(10000);\nCustRec.Rename(10001);\n```\n## Example 2\nThis example shows that you get an error if you attempt to rename a record after a newer version of the record has been written and committed to the database.\nIn this example, you get a copy of a record from the Customer table and put it into the CustRec1 variable, then you modify the record. Next, you get a copy of the same record from the Customer table and put it into the CustRec2 variable. You modify the record and commit the changes to the database. Now the CustRec1 variable is out of date with the value in the database. If you were allowed to modify the record using the CustRec1 record, then the changes that you made with CustRec2 would be overwritten by the values in the CustRec1 variable. It is not allowed to rename a record with the old version of the record.\n> NOTE\n> If you do not call the Commit method in this example, then you do not receive an error.\n```al\nvar\n    CustRec1: Record Customer;\n    CustRec2: Record Customer;\n...\n    CustRec1.LockTable();\n    CustRec1.Get(20000);\n    CustRec1.\"Address 2\" := 'Suite 102';\n    CustRec1.Modify();\n\n    CustRec2.Get(20000);\n    CustRec2.\"Phone No.\" := '206-555-0109';\n    CustRec2.Modify();\n\n    Commit();\n\n    CustRec1.\"Phone No.\" := '425-555-0184';\n    CustRec1.Rename(20001);\n```\n`The changes to the Customer record cannot be saved because some information on the page is not up-to-date. Close the page, reopen it, and try again. Identification fields and values: No.='20000'`\n## Related information\nrecord-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}