Skip to content

Latest commit

 

History

History
76 lines (60 loc) · 2.81 KB

session-stopsession-method.md

File metadata and controls

76 lines (60 loc) · 2.81 KB
title description ms.author ms.date ms.topic author ms.reviewer
Session.StopSession(Integer [, Text]) Method
Stops a session.
solsen
08/26/2024
reference
SusanneWindfeldPedersen
solsen

Session.StopSession(Integer [, Text]) Method

Version: Available or changed with runtime version 1.0.

Stops a session.

Syntax

[Ok := ]  Session.StopSession(SessionId: Integer [, Comment: Text])

Note

This method can be invoked without specifying the data type name.

Parameters

SessionId
 Type: Integer
The ID of the session that you want to stop.The session can be any of the following:

  • Windows client session
  • Web client session
  • NAS services session
  • SOAP web services client session
  • OData web services client session
  • Background session

[Optional] Comment
 Type: Text
An optional comment about the session event. The comment is stored in Table 2000000111, the Session Event table.

Return Value

[Optional] Ok
 Type: Boolean
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

The session that you want to stop and the session that calls StopSession must be running on the same instance of [!INCLUDEd365fin_server_md]. The session is stopped before the next AL statement executes. Open transactions are rolled back.

Note

If the current executing statement is the Sleep method, then the session is stopped immediately.

When a session is executing AL that does not interact with the server connection or the access lock used by the connection, StopSession cannot terminate the connection. StopSession can terminate connections that are inactive, idle, or using the database but not blocked.

You cannot stop the current, active session in which you are executing the StopSession call.

Example

This example assumes that you have a table named CacheStressTest that you use for testing.

var
    CacheStressTestRec: Record Customer;
    SessionID: Integer;
begin
    StartSession(SessionId, CodeUnit::"Cache Stress Test", CompanyName, CacheStressTestRec);  
    StopSession(SessionId, 'Logoff cache stress test session');  
end;

Related information

Session Data Type
Get Started with AL
Developing Extensions