{"title":"Codeunit.Run(var Record) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/codeunit/codeunitinstance-run-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/codeunit/codeunitinstance-run-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/codeunit/codeunitinstance-run-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":"Loads and executes the unit of AL code that you specify.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Codeunit.Run(var Record) Method","slug":"codeunitrunvar-record-method","at":0,"chars":1471},{"level":2,"title":"Syntax","slug":"syntax","at":151,"chars":63},{"level":2,"title":"Parameters","slug":"parameters","at":214,"chars":199},{"level":2,"title":"Return Value","slug":"return-value","at":413,"chars":238},{"level":2,"title":"Transaction semantics","slug":"transaction-semantics","at":651,"chars":168},{"level":2,"title":"Example","slug":"example","at":819,"chars":516},{"level":2,"title":"Related information","slug":"related-information","at":1335,"chars":136}],"text":"# Codeunit.Run(var Record) Method\n> Version: _Available or changed with runtime version 1.0._\nLoads and executes the unit of AL code that you specify.\n## Syntax\n```al\n[Ok := ]  Codeunit.Run(var Record: Record)\n```\n## Parameters\nCodeunit\nType: codeunit-data-type\nAn instance of the codeunit-data-type data type.\nRecord\nType: ../record/record-data-type\nA record from the table that is associated with the codeunit.\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## Transaction semantics\nFor information about transaction and commit semantics for Codeunit.Run, see Codeunit.Run(Integer [, var Record]) Method<codeunit-run-method>.\n## Example\nThis example runs two codeunits. The first uses a record parameter. The second is defined without a source table.\n```al\nvar\n    FiscalYearCloseInstance: Codeunit \"Fiscal Year-Close\";\n    AppMgmtInstance: Codeunit ApplicationManagement;\n    AccountRecord: Record \"Accounting Period\";\nbegin\n    AccountRecord.Init;\n    if not FiscalYearCloseInstance.Run(AccountRecord) then\n      Error('Codeunit run failed (with record).');\n    if not AppMgmtInstance.Run then\n      Error('Codeunit run failed.');\nend;\n```\n## Related information\ncodeunit-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}