bcquality/microsoft/knowledge/performance/oncompanyopen-subscribers-must-not-do-io.good.al
Jesper Schulz-Wedde 4f0a13a801
Promote knowledge for Microsoft review skills (#153)
Move canonical knowledge for Microsoft-owned review domains into the Microsoft layer and document the skill/knowledge co-location policy.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
Copilot-Session: 2a6ea875-d38e-4f30-aadb-0d606f9be231
2026-09-03 15:06:01 +02:00

30 lines
1.2 KiB
AL

codeunit 50100 "Login Subscriber IO Good"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"System Initialization", OnAfterLogin, '', false, false)]
local procedure OnAfterLogin()
var
TaskId: Guid;
StoredId: Text;
begin
// Guard to interactive sessions only; background task sessions also raise OnAfterLogin.
if not (Session.CurrentClientType() in [ClientType::Web, ClientType::Windows, ClientType::Desktop, ClientType::Tablet, ClientType::Phone]) then
exit;
// Idempotent: TaskExists requires the GUID returned by CreateTask, stored across logins.
if IsolatedStorage.Get('LoginSyncTaskId', DataScope::Company, StoredId) then
if Evaluate(TaskId, StoredId) then
if TaskScheduler.TaskExists(TaskId) then
exit;
TaskId := TaskScheduler.CreateTask(Codeunit::"Login Subscriber IO Work", 0, true, CompanyName(), CurrentDateTime() + 60000);
IsolatedStorage.Set('LoginSyncTaskId', Format(TaskId), DataScope::Company);
end;
}
codeunit 50101 "Login Subscriber IO Work"
{
trigger OnRun()
begin
// Isolated from session creation: outbound I/O is safe here.
end;
}