Customize User Login/Logout Information in Business Central – Part 1
Standard Business Central User Time Register feature provide information of How long a User stay in system by minutes. User Time Register feature is good, but people request more information like when user login and logout date & time.
We can do some simple customization and present those information to user as a page. Summary about the customization.
- Create a table object to hold user login/logout DateTime information
- Create a list page object and user able to search this page in business central
- Create a codeunit object to insert information to the table in point 1
Table object
table 57080 "User Entry Log"
{
Caption = 'User Entry Log';
DataClassification = EndUserIdentifiableInformation;
fields
{
field(1; "User ID"; Code[50])
{
Caption = 'User ID';
DataClassification = EndUserIdentifiableInformation;
NotBlank = true;
TableRelation = User."User Name";
ValidateTableRelation = false;
trigger OnValidate()
var
UserSelection: Codeunit "User Selection";
begin
UserSelection.ValidateUserName("User ID");
end;
}
field(2; "Login DateTime"; DateTime)
{
Caption = 'Login DateTime';
DataClassification = EndUserIdentifiableInformation;
}
field(3; "Logout DateTime"; DateTime)
{
Caption = 'Logout DateTime';
DataClassification = EndUserIdentifiableInformation;
}
}
keys
{
key(PK; "User ID", "Login DateTime")
{
Clustered = true;
}
}
}
List Page object
page 57080 "User Entry Logs"
{
PageType = List;
ApplicationArea = All;
UsageCategory = Lists;
SourceTable = "User Entry Log";
InsertAllowed = false;
ModifyAllowed = false;
layout
{
area(Content)
{
repeater(GroupName)
{
field("User ID"; "User ID")
{
ApplicationArea = All;
}
field("Login DateTime"; "Login DateTime")
{
ApplicationArea = All;
}
field("Logout DateTime"; "Logout DateTime")
{
ApplicationArea = All;
}
}
}
}
}
Codeunit object
codeunit 57080 "User Entry Management"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::LogInManagement, 'OnAfterLogInEnd', '', false, false)]
local procedure HandleOnAfterLogInEnd()
var
Session: Record Session;
UserEntryLog: Record "User Entry Log";
begin
if UserId = '' then begin
exit;
end;
Session.Reset();
session.setrange("My Session", true);
if session.FindFirst() then begin
if session."User ID" = userid then begin
UserEntryLog.Init();
UserEntryLog."User ID" := Session."User ID";
UserEntryLog."Login DateTime" := CreateDateTime(Session."Login Date", Session."Login Time");
UserEntryLog."Logout DateTime" := CurrentDateTime;
UserEntryLog.Insert;
end;
end;
end;
}
Result in Tell Me feature searching function
Details show in list page
Comments
-
We have basic information of user login/logout, you can refer to [Part 1] for details Now we going to change the objects to have more information about user. The information including: Client Type Database Name Client Computer Name Server Inst...

Like
Report
*This post is locked for comments