From 3f2a0d504c1ac7c71b98ef92d332cf6cd38a160a Mon Sep 17 00:00:00 2001 From: Quentin Tresontani Date: Tue, 21 Apr 2026 19:27:17 +0200 Subject: [PATCH 1/2] [Agent] Filter agent lists to current company and improve Agent Creation Control page --- .../AgentCreationControl.Page.al | 1 - .../AgentCreationControlPart.Page.al | 3 +- .../App/Agent/Setup/AgentList.Page.al | 48 ++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControl.Page.al b/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControl.Page.al index e03cb9c449..cfd476f57b 100644 --- a/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControl.Page.al +++ b/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControl.Page.al @@ -17,7 +17,6 @@ page 4326 "Agent Creation Control" PageType = ListPlus; InsertAllowed = false; DeleteAllowed = false; - SourceTable = "Agent Creation Control"; UsageCategory = Administration; DelayedInsert = true; diff --git a/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControlPart.Page.al b/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControlPart.Page.al index 2a3ab6ce5c..b30f5d0881 100644 --- a/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControlPart.Page.al +++ b/src/System Application/App/Agent/Setup/AgentCreationControls/AgentCreationControlPart.Page.al @@ -60,6 +60,7 @@ page 4332 "Agent Creation Control Part" } field(Description; Rec.Description) { + ShowMandatory = true; } } } @@ -100,7 +101,7 @@ page 4332 "Agent Creation Control Part" CreationControlLookup.LookupMode := true; if CreationControlLookup.RunModal() = Action::LookupOK then begin CreationControlLookup.GetRecord(TempAgentCreationControlLookup); - Rec."Company Name" := CopyStr(TempAgentCreationControlLookup."Key", 1, MaxStrLen(Rec."Company Name")); + Rec.Validate(Rec."Company Name", CopyStr(TempAgentCreationControlLookup."Key", 1, MaxStrLen(Rec."Company Name"))); UpdateDisplayTexts(); end; end; diff --git a/src/System Application/App/Agent/Setup/AgentList.Page.al b/src/System Application/App/Agent/Setup/AgentList.Page.al index 44e284054d..d7918fd8c3 100644 --- a/src/System Application/App/Agent/Setup/AgentList.Page.al +++ b/src/System Application/App/Agent/Setup/AgentList.Page.al @@ -10,7 +10,7 @@ page 4316 "Agent List" PageType = List; ApplicationArea = All; UsageCategory = Administration; - SourceTable = "Agent"; + SourceTable = Agent; Caption = 'Agents', Comment = 'Agents in this page should be translated as AI agents. It is listing the AI agents that users have setup to help with automating tasks.'; CardPageId = "Agent Card"; AdditionalSearchTerms = 'Agent, Agents, Copilot, Automation, AI'; @@ -47,6 +47,11 @@ page 4316 "Agent List" { Caption = 'State'; } + field("Can Access Current Company"; Rec."Can Access Current Company") + { + Caption = 'Can Access Current Company'; + Visible = ShowAllCompanies; + } } } } @@ -107,6 +112,34 @@ page 4316 "Agent List" AgentConsumptionOverview.OpenAgentConsumptionOverview(Rec."User Security ID"); end; } + action(ShowCurrentCompany) + { + ApplicationArea = All; + Caption = 'Show agents for current company'; + ToolTip = 'Show only agents that can access the current company.'; + Image = FilterLines; + Visible = ShowAllCompanies; + + trigger OnAction() + begin + ShowAllCompanies := false; + SetCompanyFilter(); + end; + } + action(ShowAllCompanies) + { + ApplicationArea = All; + Caption = 'Show agents for all companies'; + ToolTip = 'Show agents from all companies.'; + Image = RemoveFilterLines; + Visible = not ShowAllCompanies; + + trigger OnAction() + begin + ShowAllCompanies := true; + SetCompanyFilter(); + end; + } } area(Navigation) { @@ -143,6 +176,9 @@ page 4316 "Agent List" // Check if there are any agents available if AgentMetadataProvider.Names().Count() = 0 then AgentImpl.ShowNoAgentsAvailableNotification(); + + ShowAllCompanies := false; + SetCompanyFilter(); end; trigger OnAfterGetCurrRecord() @@ -162,7 +198,17 @@ page 4316 "Agent List" CopilotAvailabilityTxt := AgentImpl.GetCopilotAvailabilityDisplayText(Rec); end; + local procedure SetCompanyFilter() + begin + if ShowAllCompanies then + Rec.SetRange("Can Access Current Company") + else + Rec.SetRange("Can Access Current Company", true); + CurrPage.Update(false); + end; + var CopilotAvailabilityTxt: Text; + ShowAllCompanies: Boolean; NoAgentSetupErr: Label 'No agents have been setup. You must set up an agent first.'; } \ No newline at end of file From 3da48084fe8713d0a9116dfa1036d6537818b5e0 Mon Sep 17 00:00:00 2001 From: Quentin Tresontani Date: Tue, 21 Apr 2026 20:25:28 +0200 Subject: [PATCH 2/2] Update variable name --- .../App/Agent/Setup/AgentList.Page.al | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/System Application/App/Agent/Setup/AgentList.Page.al b/src/System Application/App/Agent/Setup/AgentList.Page.al index d7918fd8c3..9cffc7c83a 100644 --- a/src/System Application/App/Agent/Setup/AgentList.Page.al +++ b/src/System Application/App/Agent/Setup/AgentList.Page.al @@ -50,7 +50,7 @@ page 4316 "Agent List" field("Can Access Current Company"; Rec."Can Access Current Company") { Caption = 'Can Access Current Company'; - Visible = ShowAllCompanies; + Visible = ShouldShowAllCompanies; } } } @@ -118,11 +118,11 @@ page 4316 "Agent List" Caption = 'Show agents for current company'; ToolTip = 'Show only agents that can access the current company.'; Image = FilterLines; - Visible = ShowAllCompanies; + Visible = ShouldShowAllCompanies; trigger OnAction() begin - ShowAllCompanies := false; + ShouldShowAllCompanies := false; SetCompanyFilter(); end; } @@ -132,11 +132,11 @@ page 4316 "Agent List" Caption = 'Show agents for all companies'; ToolTip = 'Show agents from all companies.'; Image = RemoveFilterLines; - Visible = not ShowAllCompanies; + Visible = not ShouldShowAllCompanies; trigger OnAction() begin - ShowAllCompanies := true; + ShouldShowAllCompanies := true; SetCompanyFilter(); end; } @@ -177,7 +177,7 @@ page 4316 "Agent List" if AgentMetadataProvider.Names().Count() = 0 then AgentImpl.ShowNoAgentsAvailableNotification(); - ShowAllCompanies := false; + ShouldShowAllCompanies := false; SetCompanyFilter(); end; @@ -200,7 +200,7 @@ page 4316 "Agent List" local procedure SetCompanyFilter() begin - if ShowAllCompanies then + if ShouldShowAllCompanies then Rec.SetRange("Can Access Current Company") else Rec.SetRange("Can Access Current Company", true); @@ -209,6 +209,6 @@ page 4316 "Agent List" var CopilotAvailabilityTxt: Text; - ShowAllCompanies: Boolean; + ShouldShowAllCompanies: Boolean; NoAgentSetupErr: Label 'No agents have been setup. You must set up an agent first.'; } \ No newline at end of file