Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,32 @@ codeunit 6125 "Prepare Purchase E-Doc. Draft" implements IProcessStructuredData

// If we can't find a vendor
EDocImpSessionTelemetry.SetBool('Vendor', EDocumentPurchaseHeader."[BC] Vendor No." <> '');
if EDocumentPurchaseHeader."[BC] Vendor No." = '' then
exit;
if EDocumentPurchaseHeader."[BC] Vendor No." <> '' then begin

// Get all purchase lines for the document
EDocumentPurchaseLine.SetRange("E-Document Entry No.", EDocument."Entry No");
// Get all purchase lines for the document
EDocumentPurchaseLine.SetRange("E-Document Entry No.", EDocument."Entry No");

// Apply basic unit of measure and text-to-account resolution first
// Apply basic unit of measure and text-to-account resolution first
if EDocumentPurchaseLine.FindSet() then
repeat
UnitOfMeasure := IUnitOfMeasureProvider.GetUnitOfMeasure(EDocument, EDocumentPurchaseLine."Line No.", EDocumentPurchaseLine."Unit of Measure");
EDocumentPurchaseLine."[BC] Unit of Measure" := UnitOfMeasure.Code;
IPurchaseLineProvider.GetPurchaseLine(EDocumentPurchaseLine);
EDocumentPurchaseLine.Modify();
until EDocumentPurchaseLine.Next() = 0;

// Apply all Copilot-powered matching techniques to the lines
CopilotLineMatching(EDocument."Entry No", EDocumentPurchaseHeader."[BC] Vendor No.");
end;

// Log telemetry and activity sessions
Clear(EDocumentPurchaseLine);
EDocumentPurchaseLine.SetRange("E-Document Entry No.", EDocument."Entry No");
if EDocumentPurchaseLine.FindSet() then
repeat
UnitOfMeasure := IUnitOfMeasureProvider.GetUnitOfMeasure(EDocument, EDocumentPurchaseLine."Line No.", EDocumentPurchaseLine."Unit of Measure");
EDocumentPurchaseLine."[BC] Unit of Measure" := UnitOfMeasure.Code;
IPurchaseLineProvider.GetPurchaseLine(EDocumentPurchaseLine);
EDocumentPurchaseLine.Modify();
EDocImpSessionTelemetry.SetLine(EDocumentPurchaseLine.SystemId);
until EDocumentPurchaseLine.Next() = 0;

// Apply all Copilot-powered matching techniques to the lines
if EDocumentPurchaseHeader."[BC] Vendor No." <> '' then
CopilotLineMatching(EDocument."Entry No", EDocumentPurchaseHeader."[BC] Vendor No.");

// Log all accumulated activity session changes at the end
LogAllActivitySessionChanges(EDocActivityLogSession);

Expand All @@ -100,14 +107,11 @@ codeunit 6125 "Prepare Purchase E-Doc. Draft" implements IProcessStructuredData
ActivityLog: Codeunit "Activity Log Builder";
ActivityLogList: List of [Codeunit "Activity Log Builder"];
Found: Boolean;
i: Integer;
begin
Clear(ActivityLogList);
EDocActivityLogSession.GetAll(ActivityLogName, ActivityLogList, Found);
if Found then
for i := 1 to ActivityLogList.Count() do begin
ActivityLog := ActivityLogList.Get(i);
ActivityLog.Log();
end;
foreach ActivityLog in ActivityLogList do
ActivityLog.Log();
end;

local procedure CopilotLineMatching(EDocumentEntryNo: Integer; VendorNo: Code[20])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ codeunit 6122 "E-Doc. Imp. Session Telemetry"
internal procedure Emit(EDocument: Record "E-Document")
var
Telemetry: Codeunit "Telemetry";
EDocumentImportProcessVersion: Enum "E-Document Import Process";
SystemID, Session : Text;
begin
Session := LowerCase(CreateGuid()).Replace('}', '').Replace('{', '');
SystemID := CreateSystemIdText(EDocument.SystemId);
EDocumentImportProcessVersion := EDocument.GetEDocumentService().GetImportProcessVersion();
Data.Set('Session', Session);
Data.Set(GetEDocSystemIdTok(), SystemID);
Data.Set('ProcessVersion', EDocumentImportProcessVersion.Names().Get(EDocumentImportProcessVersion.Ordinals.IndexOf(EDocumentImportProcessVersion.AsInteger())));
Telemetry.LogMessage('0000PJD', 'E-Document Import Session', Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::All, Data);
EmitLines(SystemID, Session);

Expand Down Expand Up @@ -85,6 +88,15 @@ codeunit 6122 "E-Doc. Imp. Session Telemetry"
Data.Set("Key", Format("Value", 0, 9));
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"E-Doc. Imp. Session Telemetry", SetLine, '', false, false)]
local procedure OnSetLine(LineId: Guid)
var
EmptyDict: Dictionary of [Text, Text];
begin
if not LineData.ContainsKey(LineId) then
LineData.Set(LineId, EmptyDict);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"E-Doc. Imp. Session Telemetry", SetLineBool, '', false, false)]
local procedure OnSetLineBool(LineId: Guid; "Key": Text; "Value": Boolean)
var
Expand Down Expand Up @@ -117,6 +129,11 @@ codeunit 6122 "E-Doc. Imp. Session Telemetry"
begin
end;

[IntegrationEvent(false, false)]
procedure SetLine(LineId: Guid)
begin
end;

[IntegrationEvent(false, false)]
procedure SetLineBool(LineId: Guid; "Key": Text; "Value": Boolean)
begin
Expand Down
Loading