{"title":"Session.StartSession(var Integer, Integer, Text, var Record, Duration) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/session/session-startsession-integer-integer-string-table-duration-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/session/session-startsession-integer-integer-string-table-duration-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/session/session-startsession-integer-integer-string-table-duration-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":"Starts a session without a UI and runs the specified codeunit.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Session.StartSession(var Integer, Integer, Text, var Record, Duration) Method","slug":"sessionstartsessionvar-integer-integer-text-var-record-duration-method","at":0,"chars":2254},{"level":2,"title":"Syntax","slug":"syntax","at":203,"chars":225},{"level":2,"title":"Parameters","slug":"parameters","at":428,"chars":949},{"level":2,"title":"Return Value","slug":"return-value","at":1377,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":1615,"chars":417},{"level":2,"title":"Related information","slug":"related-information","at":2032,"chars":222}],"text":"# Session.StartSession(var Integer, Integer, Text, var Record, Duration) Method\n> Version: _Available or changed with runtime version 7.0._\nStarts a session without a UI and runs the specified codeunit.\n## Syntax\n```al\n[Ok := ]  Session.StartSession(var SessionId: Integer, CodeunitId: Integer, Company: Text, var Record: Record, Timeout: Duration)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nSessionId\nType: ../integer/integer-data-type\nThe ID of the new session that is started. The ID is assigned to the SessionID variable after the session is started successfully. This parameter is passed by reference to the method.\nCodeunitId\nType: ../integer/integer-data-type\nThe ID of the codeunit to run when the session is started.\nCompany\nType: ../text/text-data-type\nThe company in which to start the session. By default, the session is started in the same company as the calling session.\nRecord\nType: ../record/record-data-type\nA record that is passed to the OnRun trigger of the codeunit that runs when the session is started. This parameter is optional.\nTimeout\nType: ../duration/duration-data-type\nSpecifies the timeout of the created session. If not specified a default timeout will be used; for OnPrem, the default timeout is set on the server, for SaaS the current default timeout is 12 hours, and may change in the future.\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\nThe session is started on the same Business Central instance from which the method is called. The session that is started is a background session and therefore has no UI. The session executes using the same user credentials as the calling AL code.\nFor information about how dialog boxes are handled in a background session, see session-startsession-integer-integer-string-table-method#dialog-box-behavior.\n## Related information\nsession-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\nConfiguring Business Central Server<../../../administration/configure-server-instance>"}