mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-07 15:46:55 +01:00
httpclient-inside-write-transaction-holds-locks.good.al - Pass Customer.RecordId as the last argument to CreateTask so the task is bound to the single customer that was written, not to all customers. - Declare TableNo = Customer on the task codeunit so the platform loads the bound record into Rec automatically when OnRun executes. - Replace the FindSet loop over all customers with Rec."No.", preserving the one-customer scope of the original SyncCustomerLastName procedure. oncompanyopen-subscribers-must-not-do-io.good.al - Replace Session.GetCurrentClientType() with Session.CurrentClientType(), the correct platform method name. - Fix the idempotency check: TaskScheduler.TaskExists() requires a Guid, not a codeunit integer ID. Store the Guid returned by CreateTask in IsolatedStorage (DataScope::Company) under a fixed key; on the next login read it back as Text, Evaluate it to Guid, and pass that Guid to TaskExists so the type matches the method signature.
30 lines
1.2 KiB
AL
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;
|
|
}
|