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
28 changes: 27 additions & 1 deletion src/System Application/App/Agent/Setup/Agent.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,33 @@ codeunit 4321 Agent
var
AgentImpl: Codeunit "Agent Impl.";
begin
AgentImpl.UpdateAgentAccessControl(AgentUserSecurityID, TempAgentAccessControl);
AgentImpl.UpdateAccessControl(AgentUserSecurityID, TempAgentAccessControl);
end;

/// <summary>
/// Gets the access controls for the agent when executing tasks.
/// </summary>
/// <param name="AgentUserSecurityID">Security ID of the agent.</param>
/// <param name="TempAccessControlBuffer">List of access controls for the agent used when executing tasks.</param>
[Scope('OnPrem')]
procedure GetAccessControl(AgentUserSecurityID: Guid; var TempAccessControlBuffer: Record "Access Control Buffer" temporary)
var
AgentImpl: Codeunit "Agent Impl.";
begin
AgentImpl.GetAccessControl(AgentUserSecurityID, TempAccessControlBuffer);
end;

/// <summary>
/// Sets access controls for the agent used when executing tasks. Existing set of access controls will be replaced with a new set.
/// </summary>
/// <param name="AgentUserSecurityID">Security ID of the agent.</param>
/// <param name="TempAccessControlBuffer">List of access controls for the agent used when executing tasks.</param>
[Scope('OnPrem')]
procedure UpdateAccessControl(AgentUserSecurityID: Guid; var TempAccessControlBuffer: Record "Access Control Buffer" temporary)
var
AgentImpl: Codeunit "Agent Impl.";
begin
AgentImpl.UpdateAccessControl(AgentUserSecurityID, TempAccessControlBuffer);
end;

/// <summary>
Expand Down
76 changes: 73 additions & 3 deletions src/System Application/App/Agent/Setup/AgentImpl.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,37 @@ codeunit 4301 "Agent Impl."
Error(OneOwnerMustBeDefinedForAgentErr);
end;

internal procedure GetAccessControl(AgentUserSecurityID: Guid; var TempAccessControlBuffer: Record "Access Control Buffer" temporary)
var
AccessControl: Record "Access Control";
Agent: Record Agent;
begin
GetAgent(Agent, AgentUserSecurityID);

GetAccessControl(Agent, TempAccessControlBuffer);
end;

local procedure GetAccessControl(Agent: Record Agent; var TempAccessControlBuffer: Record "Access Control Buffer" temporary)
var
AccessControl: Record "Access Control";
begin
TempAccessControlBuffer.Reset();
TempAccessControlBuffer.DeleteAll();

AccessControl.SetRange("User Security ID", Agent."User Security ID");
if AccessControl.IsEmpty() then
exit;

AccessControl.FindSet();
repeat
TempAccessControlBuffer."Company Name" := AccessControl."Company Name";
TempAccessControlBuffer.Scope := AccessControl.Scope;
TempAccessControlBuffer."App ID" := AccessControl."App ID";
TempAccessControlBuffer."Role ID" := AccessControl."Role ID";
TempAccessControlBuffer.Insert();
until AccessControl.Next() = 0;
end;

internal procedure GetUserAccess(AgentUserSecurityID: Guid; var TempAgentAccessControl: Record "Agent Access Control" temporary)
var
Agent: Record Agent;
Expand Down Expand Up @@ -259,12 +290,20 @@ codeunit 4301 "Agent Impl."
exit(Agent.State = Agent.State::Enabled);
end;

internal procedure UpdateAgentAccessControl(AgentUserSecurityID: Guid; var TempAgentAccessControl: Record "Agent Access Control" temporary)
procedure UpdateAccessControl(AgentUserSecurityID: Guid; var TempAccessControlBuffer: Record "Access Control Buffer" temporary)
var
Agent: Record Agent;
begin
if not Agent.Get(AgentUserSecurityID) then
Error(AgentDoesNotExistErr);
GetAgent(Agent, AgentUserSecurityID);

UpdateAccessControl(TempAccessControlBuffer, Agent);
end;

internal procedure UpdateAccessControl(AgentUserSecurityID: Guid; var TempAgentAccessControl: Record "Agent Access Control" temporary)
var
Agent: Record Agent;
begin
GetAgent(Agent, AgentUserSecurityID);

UpdateAgentAccessControl(TempAgentAccessControl, Agent);
end;
Expand Down Expand Up @@ -434,6 +473,37 @@ codeunit 4301 "Agent Impl."
end;
end;

local procedure UpdateAccessControl(var TempAccessControlBuffer: Record "Access Control Buffer" temporary; var Agent: Record Agent)
AccessControl: Record "Access Control";
begin
// Delete records for the agent user ID which are not present in the temporary record.
AccessControl.SetRange("User Security ID", Agent."User Security ID");
if AccessControl.FindSet() then
repeat
if not TempAccessControlBuffer.Get(AccessControl."Company Name", AccessControl.Scope, AccessControl."App ID", AccessControl."Role ID") then
AccessControl.Delete();
until AccessControl.Next() = 0;

if TempAccessControlBuffer.FindSet() then
repeat
if AccessControl.Get(Agent."User Security ID", TempAccessControlBuffer."Role ID", TempAccessControlBuffer."Company Name", TempAccessControlBuffer.Scope, TempAccessControlBuffer."App ID") then begin
AccessControl."User Security ID" := Agent."User Security ID";
AccessControl."Role ID" := TempAccessControlBuffer."Role ID";
AccessControl."Company Name" := TempAccessControlBuffer."Company Name";
AccessControl.Scope := TempAccessControlBuffer.Scope;
AccessControl."App ID" := TempAccessControlBuffer."App ID";
AccessControl.Modify();
end else begin
AccessControl."User Security ID" := Agent."User Security ID";
AccessControl."Role ID" := TempAccessControlBuffer."Role ID";
AccessControl."Company Name" := TempAccessControlBuffer."Company Name";
AccessControl.Scope := TempAccessControlBuffer.Scope;
AccessControl."App ID" := TempAccessControlBuffer."App ID";
AccessControl.Insert();
end;
until TempAccessControlBuffer.Next() = 0;
end;

procedure SelectAgent(var Agent: Record "Agent")
begin
Agent.SetRange(State, Agent.State::Enabled);
Expand Down
1 change: 1 addition & 0 deletions src/System Application/App/Diagnostics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module provides an interface for working with diagnostics.
31 changes: 31 additions & 0 deletions src/System Application/App/Diagnostics/Severity.Enum.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.Tooling;

enum 9190 Severity
{
Extensible = true;
AssignmentCompatibility = true;

value(1; Critical)
{
}
value(2; Error)
{
}
value(3; Warning)
{
}
value(4; Information)
{
}
value(5; Verbose)
{
}
value(10; Hidden)
{
}
}
24 changes: 24 additions & 0 deletions src/System Application/App/Diagnostics/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"id": "9d986d74-50e6-438e-9e66-a1dd4cce9ad3",
"name": "Diagnostics",
"publisher": "Microsoft",
"description": "This module provides an interface for working with diagnostics.",
"version": "28.0.0.0",
"privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009",
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
"help": "https://go.microsoft.com/fwlink/?linkid=2104024",
"url": "https://go.microsoft.com/fwlink/?LinkId=724011",
"screenshots": [],
"internalsVisibleTo": [],
"platform": "28.0.0.0",
"idRanges": [
{
"from": 1,
"to": 9999
}
],
"target": "OnPrem",
"features": [
"NoImplicitWith"
]
}
Loading