-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathAgentSetup.Codeunit.al
More file actions
167 lines (150 loc) · 8.16 KB
/
AgentSetup.Codeunit.al
File metadata and controls
167 lines (150 loc) · 8.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace System.Agents;
using System.Environment;
using System.Environment.Configuration;
/// <summary>
/// Used for setting up new agents and configuring existing agents.
/// </summary>
codeunit 4324 "Agent Setup"
{
InherentEntitlements = X;
InherentPermissions = X;
/// <summary>
/// Gets the setup record for existing agents or initializes a new setup record for new agents.
/// </summary>
/// <param name="AgentSetupBuffer"><see cref="AgentSetupBuffer"/> that contains the setup data.</param>
/// <param name="UserSecurityID">Agent User Security ID, should be null for new agents</param>
/// <param name="AgentMetadataProvider">Type of the agent that is being initialized</param>
/// <param name="DefaultUserName">Default user name for new agents</param>
/// <param name="DefaultDisplayName">Default display name for new agents</param>
/// <param name="AgentSummary">Summary information about the agent</param>
procedure GetSetupRecord(var AgentSetupBuffer: Record "Agent Setup Buffer"; UserSecurityID: Guid; AgentMetadataProvider: Enum "Agent Metadata Provider"; DefaultUserName: Code[50]; DefaultDisplayName: Text[80]; AgentSummary: Text)
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
AgentSetupImpl.GetSetupRecord(AgentSetupBuffer, UserSecurityID, AgentMetadataProvider, DefaultUserName, DefaultDisplayName, AgentSummary);
end;
/// <summary>
/// Copies the setup record from the source buffer to the target buffer.
/// </summary>
/// <param name="Target"><see cref="AgentSetupBuffer"/> that will receive the setup data.</param>
/// <param name="Source"><see cref="AgentSetupBuffer"/> that contains the setup data to be copied.</param>
procedure CopySetupRecord(var Target: Record "Agent Setup Buffer"; var Source: Record "Agent Setup Buffer")
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
AgentSetupImpl.CopySetupRecord(Target, Source);
end;
/// <summary>
/// Saves changes done. If the agent does not exist we will create a new agent otherwise we will update the agent.
/// </summary>
/// <param name="AgentSetupBuffer"><see cref="AgentSetupBuffer"/> that contains the setup data.</param>
/// <returns>Agent User ID of the created or updated agent.</returns>
procedure SaveChanges(var AgentSetupBuffer: Record "Agent Setup Buffer") "Agent User ID": Guid
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.SaveChanges(AgentSetupBuffer));
end;
/// <summary>
/// Checks if there are any changes made in the setup buffer that need to be saved.
/// </summary>
/// <param name="AgentSetupBuffer"><see cref="AgentSetupBuffer"/> that contains the setup data.</param>
/// <returns>True if there are changes made, false otherwise.</returns>
procedure GetChangesMade(var AgentSetupBuffer: Record "Agent Setup Buffer"): Boolean
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.GetChangesMade(AgentSetupBuffer));
end;
/// <summary>
/// Opens a page where the language and region settings for the agent can be updated.
/// </summary>
/// <param name="AgentSetupBuffer"><see cref="AgentSetupBuffer"/> that contains the setup data.</param>
/// <returns>True if the language and region settings were updated, false otherwise.</returns>
procedure OpenLanguageAndRegionPage(var AgentSetupBuffer: Record "Agent Setup Buffer"): Boolean
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.OpenLanguageAndRegionPage(AgentSetupBuffer));
end;
/// <summary>
/// Retrieves the summary information about the agent.
/// </summary>
/// <param name="AgentSetupBuffer"><see cref="AgentSetupBuffer"/> that contains the setup data.</param>
/// <returns>Summary information about the agent.</returns>
procedure GetAgentSummary(var AgentSetupBuffer: Record "Agent Setup Buffer"): Text
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.GetAgentSummary(AgentSetupBuffer));
end;
/// <summary>
/// Opens a page where the user access control settings for the agent can be updated.
/// </summary>
/// <param name="AgentSetupBuffer"><see cref="AgentSetupBuffer"/> that contains the setup data.</param>
/// <returns>True if the user access control settings were updated, false otherwise.</returns>
procedure OpenAgentAccessControlPage(var AgentSetupBuffer: Record "Agent Setup Buffer"): Boolean
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.OpenAgentAccessControlSetup(AgentSetupBuffer));
end;
/// <summary>
/// Allows the user to select a profile out of the list of available profiles.
/// The user settings record will be updated with the selected profile.
/// </summary>
/// <param name="UserSettingsRec">User settings to update with the new profile</param>
procedure OpenProfileLookup(var UserSettingsRec: Record "User Settings"): Boolean
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.OpenProfileLookup(UserSettingsRec));
end;
/// <summary>
/// Allows the user to select an agent out of the list of enabled agents.
/// </summary>
/// <returns>The security ID of the selected agent or the empty guid if none selected.</returns>
procedure OpenAgentLookup(var AgentUserSecurityId: Guid): Boolean
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.OpenAgentLookup(AgentUserSecurityId));
end;
/// <summary>
/// Allows the user to select an agent out of the list of enabled agents.
/// </summary>
/// <param name="AgentType">The type of agent to filter the lookup on.</param>
/// <returns>The security ID of the selected agent or the empty guid if none selected.</returns>
procedure OpenAgentLookup(AgentType: Enum "Agent Metadata Provider"; var AgentUserSecurityId: Guid): Boolean
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.OpenAgentLookup(AgentType, AgentUserSecurityId));
end;
/// <summary>
/// Opens the setup page for the agent.
/// </summary>
/// <param name="AgentSetupBuffer">A record that should point to the agent.</param>
procedure OpenSetupPage(var AgentSetupBuffer: Record "Agent Setup Buffer")
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
AgentSetupImpl.OpenSetupPage(AgentSetupBuffer."User Security ID");
end;
/// <summary>
/// Opens the setup page for the agent.
/// </summary>
/// <param name="AgentUserSecurityId">The user security ID of the agent.</param>
procedure OpenSetupPage(AgentUserSecurityId: Guid)
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
AgentSetupImpl.OpenSetupPage(AgentUserSecurityId);
end;
/// <summary>
/// Opens the page where the user access control settings for the agent can be updated.
/// </summary>
/// <param name="AgentSetupBuffer"><see cref="AgentSetupBuffer"/> that contains the setup data.</param>
/// <returns>True if the user access control settings were updated, false otherwise.</returns>
[Scope('OnPrem')]
procedure UpdateUserAccessControl(var AgentSetupBuffer: Record "Agent Setup Buffer"): Boolean
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
exit(AgentSetupImpl.OpenAgentAccessControlSetup(AgentSetupBuffer));
end;
var
AgentSetupImpl: Codeunit "Agent Setup Impl.";
FeatureAccessManagement: Codeunit "Feature Access Management";
}