# Record.ChangeCompany([Text]) Method
> Version: _Available or changed with runtime version 1.0._
Redirects references to table data from one company to another.
## Syntax
```al
[Ok := ]  Record.ChangeCompany([CompanyName: Text])
```
## Parameters
Record
Type: record-data-type
An instance of the record-data-type data type.
*[Optional] CompanyName*
Type: ../text/text-data-type
The name of the company to which you want to change. If you omit this parameter, you change back to the current company.
## 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
When executing this method, the user's access rights are respected. For example, a user cannot access data in CompanyName unless they already have the necessary access rights.
The ChangeCompany method is not affected by the ../recordref/recordref-reset-method. You can deselect a company by making a new call to ChangeCompany or by using the ../system/system-clear-joker-method.
Global filters always belong to a specific company. If you use the following code to select the company named NewCompany, any filters assigned to RecordRef will be transferred to RecordRef in the new company.
```al
Record.ChangeCompany(NewCompany);
```
Even if you run the ChangeCompany method, triggers still run in the current company, not in the company that you specified in the ChangeCompany method.
## Example
This example shows how to use the ChangeCompany method. The following code takes a Customer record in the current company and redirects it to the table in another company - in this case Company B. The last record in the Customer table of Company B is then deleted.
```al
codeunit 50112 ChangeCompany
{
    trigger OnRun()
    var
        RecID: RecordID;
        MyRecord: Record Customer;
        Text000: Label 'Record to be deleted: %1';
    begin
        MyRecord.ChangeCompany('Company B');
        MyRecord.FindLast;
        RecID := MyRecord.RecordId;
        Message(Text000, RecID);
        MyRecord.Delete;
    end;
}
```
## Related information
record-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/record/record-changecompany-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/record/record-changecompany-method/
