Skip to content
Open
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 @@ -185,6 +185,11 @@ codeunit 3307 "Payables Agent Setup"
exit(EDocument.GetEDocumentService().Code = PayablesAgentEDocServiceTok);
end;

procedure GetAgentEDocumentServiceCode(): Code[20]
begin
exit(PayablesAgentEDocServiceTok);
end;

/// <summary>
/// Retrieves the agent record if configured in the database, and ensures that the Payables Agent setup record is updated with the correct user security id.
/// </summary>
Expand Down
82 changes: 82 additions & 0 deletions src/Apps/W1/PayablesAgent/app/Setup/PayablesAgentSetup.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,32 @@ page 3304 "Payables Agent Setup"
Editable = false;
ToolTip = 'Specifies the total number of Copilot credits consumed by the Payables Agent.', Comment = 'Payables Agent is a term, and should not be translated.';
}
field(AgentTasks; AgentTasksText)
{
ShowCaption = false;
Editable = false;
StyleExpr = true;
Style = StandardAccent;
ToolTip = 'Specifies the number of tasks completed by the Payables Agent. Choose this field to open the agent task list.', Comment = 'Payables Agent is a term, and should not be translated.';

trigger OnDrillDown()
begin
DrillDownAgentTasks();
end;
}
field(InboundEDocuments; InboundEDocumentsText)
{
ShowCaption = false;
Editable = false;
StyleExpr = true;
Style = StandardAccent;
ToolTip = 'Specifies the number of inbound e-documents processed by the Payables Agent. Choose this field to open the list of inbound e-documents.', Comment = 'Payables Agent is a term, and should not be translated.';

trigger OnDrillDown()
begin
DrillDownInboundEDocuments();
end;
}
field(LearnMoreCost; LearnMoreCostLbl)
{
ShowCaption = false;
Expand Down Expand Up @@ -481,6 +507,58 @@ page 3304 "Payables Agent Setup"
begin
CreditsConsumed := PACostEstimate.GetCreditsConsumed();
CostEstimateText := PACostEstimate.FormatCreditsConsumed(CreditsConsumed);
CalcAgentTasks();
CalcInboundEDocuments();
end;

local procedure CalcAgentTasks()
var
AgentTask: Record "Agent Task";
PayablesAgentSetupRec: Record "Payables Agent Setup";
TaskCount: Integer;
begin
PayablesAgentSetupRec.GetSetup();
if IsNullGuid(PayablesAgentSetupRec."User Security Id") then begin
AgentTasksText := StrSubstNo(AgentTasksLbl, 0);
exit;
end;
AgentTask.SetRange("Agent User Security ID", PayablesAgentSetupRec."User Security Id");
TaskCount := AgentTask.Count();
AgentTasksText := StrSubstNo(AgentTasksLbl, TaskCount);
end;

local procedure DrillDownAgentTasks()
var
AgentTask: Record "Agent Task";
PayablesAgentSetupRec: Record "Payables Agent Setup";
AgentTaskList: Page "Agent Task List";
begin
PayablesAgentSetupRec.GetSetup();
if not IsNullGuid(PayablesAgentSetupRec."User Security Id") then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Agent} \quad \color{gray}{\texttt{\small Iteration\ 5}}$

DrillDownAgentTasks only applies the 'Agent User Security ID' filter when the setup's User Security Id is not blank; when it is blank, AgentTask is left completely unfiltered and the drill-down opens the Agent Task List showing every agent task in the system.

This contradicts CalcAgentTasks, which displays '0 agent tasks' for the exact same blank-guid condition. A user sees 0 on the field but an unfiltered, unrelated list when they click it.

Recommendation:

  • always apply the SetRange unconditionally (a blank guid filter naturally returns zero matching rows), matching CalcAgentTasks' effective behavior and removing the special-case branch.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

        PayablesAgentSetupRec.GetSetup();
        AgentTask.SetRange("Agent User Security ID", PayablesAgentSetupRec."User Security Id");
        AgentTaskList.SetTableView(AgentTask);

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

AgentTask.SetRange("Agent User Security ID", PayablesAgentSetupRec."User Security Id");
AgentTaskList.SetTableView(AgentTask);
AgentTaskList.Run();
end;

local procedure CalcInboundEDocuments()
var
EDocument: Record "E-Document";
EDocCount: Integer;
begin
EDocument.SetRange(Direction, "E-Document Direction"::Incoming);
EDocument.SetRange(Service, PayablesAgentSetup.GetAgentEDocumentServiceCode());
EDocCount := EDocument.Count();
InboundEDocumentsText := StrSubstNo(InboundEDocumentsLbl, EDocCount);
end;

local procedure DrillDownInboundEDocuments()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Agent} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

CalcInboundEDocuments counts E-Document rows filtered by both Direction = Incoming and Service, and the field caption states 'Based on %1 inbound e-documents'.

DrillDownInboundEDocuments, invoked from the same field's OnDrillDown, only filters by Service before calling Page "Inbound E-Documents".SetTableView and Run. Page.SetTableView replaces the target page's own SourceTableView (which itself filters Direction = Incoming on page 6105), so the drill-down list will include both inbound and outbound e-documents for the service, not just the inbound ones the displayed count promises. Impact would otherwise be major (visible user-facing mismatch between the shown count and the drilled-down list), but is capped to minor per agent-finding rules.

Recommendation:

  • add EDocument.SetRange(Direction, "E-Document Direction"::Incoming) in DrillDownInboundEDocuments to match the count's filter.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

    local procedure DrillDownInboundEDocuments()
    var
        EDocument: Record "E-Document";
        InboundEDocuments: Page "Inbound E-Documents";
    begin
        EDocument.SetRange(Direction, "E-Document Direction"::Incoming);
        EDocument.SetRange(Service, PayablesAgentSetup.GetAgentEDocumentServiceCode());
        InboundEDocuments.SetTableView(EDocument);
        InboundEDocuments.Run();
    end;

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

var
EDocument: Record "E-Document";
InboundEDocumentsPage: Page "Inbound E-Documents";
begin
EDocument.SetRange(Service, PayablesAgentSetup.GetAgentEDocumentServiceCode());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Agent} \quad \color{gray}{\texttt{\small Iteration\ 5}}$

CalcInboundEDocuments filters E-Document by both Direction = Incoming and Service, but DrillDownInboundEDocuments filters only by Service.

Clicking the 'InboundEDocuments' field (tooltip: 'open the list of inbound e-documents') can therefore open a list that also includes outgoing e-documents for that service, contradicting both the field's label and the count shown.

Recommendation:

  • add the same Direction = Incoming filter in DrillDownInboundEDocuments so the drill-down list matches the displayed count and the field's stated purpose.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

        EDocument.SetRange(Direction, "E-Document Direction"::Incoming);
        EDocument.SetRange(Service, PayablesAgentSetup.GetAgentEDocumentServiceCode());

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

InboundEDocumentsPage.SetTableView(EDocument);
InboundEDocumentsPage.Run();
end;

/// <summary>
Expand Down Expand Up @@ -542,6 +620,8 @@ page 3304 "Payables Agent Setup"
MailboxAddress: Text;
TrialProgressText: Text;
CostEstimateText: Text;
AgentTasksText: Text;
InboundEDocumentsText: Text;
TrialExperienceVisible: Boolean;
IsEligibleForTrialVisible: Boolean;
IsInTrialModeVisible: Boolean;
Expand All @@ -565,5 +645,7 @@ page 3304 "Payables Agent Setup"
BenefitNoDisruptionLbl: Label '• No disruption to your current process';
SelectFileLbl: Label 'Select file';
PdfFileFilterLbl: Label 'PDF Files (*.pdf)|*.pdf';
InboundEDocumentsLbl: Label 'Based on %1 inbound e-documents', Comment = '%1 is the number of inbound e-documents processed by the agent.';
AgentTasksLbl: Label '%1 agent tasks', Comment = '%1 is the number of tasks completed by the agent.';

}
Loading