{"title":"Record.ChangeCompany([Text]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/record/record-changecompany-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-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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-changecompany-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":"Redirects references to table data from one company to another.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Record.ChangeCompany([Text]) Method","slug":"recordchangecompanytext-method","at":0,"chars":2310},{"level":2,"title":"Syntax","slug":"syntax","at":162,"chars":72},{"level":2,"title":"Parameters","slug":"parameters","at":234,"chars":266},{"level":2,"title":"Return Value","slug":"return-value","at":500,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":738,"chars":795},{"level":2,"title":"Example","slug":"example","at":1533,"chars":643},{"level":2,"title":"Related information","slug":"related-information","at":2176,"chars":134}],"text":"# Record.ChangeCompany([Text]) Method\n> Version: _Available or changed with runtime version 1.0._\nRedirects references to table data from one company to another.\n## Syntax\n```al\n[Ok := ]  Record.ChangeCompany([CompanyName: Text])\n```\n## Parameters\nRecord\nType: record-data-type\nAn instance of the record-data-type data type.\n*[Optional] CompanyName*\nType: ../text/text-data-type\nThe name of the company to which you want to change. If you omit this parameter, you change back to the current company.\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\nWhen 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.\nThe 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.\nGlobal 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.\n```al\nRecord.ChangeCompany(NewCompany);\n```\nEven if you run the ChangeCompany method, triggers still run in the current company, not in the company that you specified in the ChangeCompany method.\n## Example\nThis 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.\n```al\ncodeunit 50112 ChangeCompany\n{\n    trigger OnRun()\n    var\n        RecID: RecordID;\n        MyRecord: Record Customer;\n        Text000: Label 'Record to be deleted: %1';\n    begin\n        MyRecord.ChangeCompany('Company B');\n        MyRecord.FindLast;\n        RecID := MyRecord.RecordId;\n        Message(Text000, RecID);\n        MyRecord.Delete;\n    end;\n}\n```\n## Related information\nrecord-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}