Codeunit Agent
Properties
| Name | Value |
|---|---|
| InherentEntitlements | X |
| InherentPermissions | X |
Methods
Create
Creates a new agent. The agent will be in the disabled state, with the users that can interact with the agent setup.
procedure Create(AgentMetadataProvider: Enum "Agent Metadata Provider"; var UserName: Code[50]; UserDisplayName: Text[80]; var TempAgentAccessControl: Record "Agent Access Control" temporary): Guid
Parameters
| Name | Type | Description |
|---|---|---|
| AgentMetadataProvider | Enum System.Agents."Agent Metadata Provider" |
The metadata provider of the agent. |
| UserName | Code[50] |
User name for the agent. |
| UserDisplayName | Text[80] |
Display name for the agent. |
| TempAgentAccessControl | Table System.Agents."Agent Access Control" |
The list of users that can configure or interact with the agent. |
Returns
| Type | Description |
|---|---|
| Guid |
The ID of the agent. |
Activate
Activates the agent
procedure Activate(AgentUserSecurityID: Guid)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
Deactivate
Deactivates the agent
procedure Deactivate(AgentUserSecurityID: Guid)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
GetDisplayName
Get the display name of the agent.
procedure GetDisplayName(AgentUserSecurityID: Guid): Text[80]
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
Returns
| Type | Description |
|---|---|
| Text[80] |
GetUserName
Get the user name of the agent.
procedure GetUserName(AgentUserSecurityID: Guid): Code[50]
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
Returns
| Type | Description |
|---|---|
| Code[50] |
SetDisplayName
Sets the display name of the agent.
procedure SetDisplayName(AgentUserSecurityID: Guid; DisplayName: Text[80])
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
| DisplayName | Text[80] |
The display name of the agent. |
SetInstructions
Set the instructions which agent will use to complete the tasks.
procedure SetInstructions(AgentUserSecurityID: Guid; Instructions: SecretText)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid | |
| Instructions | SecretText |
Instructions for the agent that will be used to complete the tasks. |
IsActive
Checks if the agent is active.
procedure IsActive(AgentUserSecurityID: Guid): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
Returns
| Type | Description |
|---|---|
| Boolean |
If the agent is active. |
PopulateDefaultProfile
Populates the temporary profile record with the specified information.
procedure PopulateDefaultProfile(ProfileID: Text[30]; ProfileAppID: Guid; var TempAllProfile: Record "All Profile" temporary)
Parameters
| Name | Type | Description |
|---|---|---|
| ProfileID | Text[30] |
The profile ID. |
| ProfileAppID | Guid |
The profile App ID. |
| TempAllProfile | Table System.Reflection."All Profile" |
The profile record. |
SetProfile
Assigns the profile to the agent.
procedure SetProfile(AgentUserSecurityID: Guid; ProfileID: Text; ProfileAppID: Guid)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
| ProfileID | Text |
The profile ID. |
| ProfileAppID | Guid |
The profile App ID. |
UpdateLocalizationSettings
Updates the Language, Regional Settings and Time Zone for the agent.
procedure UpdateLocalizationSettings(AgentUserSecurityID: Guid; LanguageID: Integer; LocaleID: Integer; TimeZone: Text[180])
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
| LanguageID | Integer |
The language ID to set. |
| LocaleID | Integer |
The locale ID to set. |
| TimeZone | Text[180] |
The time zone to set. |
GetUserSettings
Gets the user settings for the agent. Few properties are retrieved, like: Profile, Language, Regional Settings and Time Zone.
procedure GetUserSettings(AgentUserSecurityID: Guid; var UserSettingsRec: Record "User Settings")
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
| UserSettingsRec | Table System.Environment.Configuration."User Settings" |
The user settings for the agent. If agent is not created yet, it will use the current user settings |
UpdateAccessControl
Assigns one or multiple permission sets to the agent. The assignment overrides any existing permission sets.
procedure UpdateAccessControl(AgentUserSecurityID: Guid; var TempAccessControlBuffer: Record "Access Control Buffer" temporary)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
| TempAccessControlBuffer | Table System.Security.AccessControl."Access Control Buffer" |
The access controls to assign |
Remarks
The values need to be inserted to the temporary record. If none are inserted, all permissions will be removed from the agent.
GetAccessControl
Gets the permission sets assigned to the agent.
procedure GetAccessControl(AgentUserSecurityID: Guid; var TempAccessControlBuffer: Record "Access Control Buffer" temporary)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
The user security ID of the agent. |
| TempAccessControlBuffer | Table System.Security.AccessControl."Access Control Buffer" |
The access controls assigned to the agent. |
GetAgentAccessControl
Gets the users that can manage or give tasks to the agent.
procedure GetAgentAccessControl(AgentUserSecurityID: Guid; var TempAgentAccessControl: Record "Agent Access Control" temporary)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
Security ID of the agent. |
| TempAgentAccessControl | Table System.Agents."Agent Access Control" |
List of users that can manage or give tasks to the agent. |
UpdateAgentAccessControl
Sets the users that can manage or give tasks to the agent. Existing set of users will be replaced with a new set.
procedure UpdateAgentAccessControl(AgentUserSecurityID: Guid; var TempAgentAccessControl: Record "Agent Access Control" temporary)
Parameters
| Name | Type | Description |
|---|---|---|
| AgentUserSecurityID | Guid |
Security ID of the agent. |
| TempAgentAccessControl | Table System.Agents."Agent Access Control" |
List of users that can manage or give tasks to the agent. |