Codeunit "Agent Task"

ID 4303
Namespace: System.Agents

Properties

Name Value
InherentEntitlements X
InherentPermissions X

Methods

TaskExists

Check if a task exists for the given agent user and conversation

procedure TaskExists(AgentUserSecurityId: Guid; ExternalId: Text): Boolean

Parameters

Name Type Description
AgentUserSecurityId Guid

The user security ID of the agent.

ExternalId Text

The external ID to check.

Returns

Type Description
Boolean

True if task exists, false if not.

GetTaskByExternalId

Get the task for the given agent user and external ID.

procedure GetTaskByExternalId(AgentUserSecurityId: Guid; ExternalId: Text): Record "Agent Task"

Parameters

Name Type Description
AgentUserSecurityId Guid

The agent user ID.

ExternalId Text

The external ID of the task.

Returns

Type Description
Table System.Agents."Agent Task"

A record with the given task.

SetStatusToReady

Set the status of the task to ready if the task is in the state that it can be started again. The agent task will be be picked up for processing shortly after updating the status.

procedure SetStatusToReady(var AgentTask: Record "Agent Task")

Parameters

Name Type Description
AgentTask Table System.Agents."Agent Task"

The agent task to set to ready.

CanSetStatusToReady

Checks if the task can be set to ready and started again.

procedure CanSetStatusToReady(AgentTask: Record "Agent Task"): Boolean

Parameters

Name Type Description
AgentTask Table System.Agents."Agent Task"

The agent task to check.

Returns

Type Description
Boolean

True if agent task can be set to ready, false otherwise

StopTask

Stops the agent task.

procedure StopTask(var AgentTask: Record "Agent Task"; UserConfirm: Boolean)

Parameters

Name Type Description
AgentTask Table System.Agents."Agent Task"

The agent task to stop.

UserConfirm Boolean

Whether to show a confirmation dialog to the user.

RestartTask

Restarts the agent task by setting its status to ready.

procedure RestartTask(var AgentTask: Record "Agent Task"; UserConfirm: Boolean)

Parameters

Name Type Description
AgentTask Table System.Agents."Agent Task"

The agent task to restart.

UserConfirm Boolean

Whether to show a confirmation dialog to the user.

IsTaskRunning

Checks if the agent task is currently running.

procedure IsTaskRunning(var AgentTask: Record "Agent Task"): Boolean

Parameters

Name Type Description
AgentTask Table System.Agents."Agent Task"

The agent task to check.

Returns

Type Description
Boolean

True if the task is running, false otherwise.

IsTaskCompleted

Checks if the agent task is completed.

procedure IsTaskCompleted(var AgentTask: Record "Agent Task"): Boolean

Parameters

Name Type Description
AgentTask Table System.Agents."Agent Task"

The agent task to check.

Returns

Type Description
Boolean

True if the task is completed, false otherwise.

IsTaskStopped

Checks if the agent task is stopped (by user or system).

procedure IsTaskStopped(var AgentTask: Record "Agent Task"): Boolean

Parameters

Name Type Description
AgentTask Table System.Agents."Agent Task"

The agent task to check.

Returns

Type Description
Boolean

True if the task is stopped, false otherwise.

GetCopilotCreditsConsumed

Gets the total Copilot credits consumed by the agent task.

procedure GetCopilotCreditsConsumed(AgentTaskID: BigInteger): Decimal

Parameters

Name Type Description
AgentTaskID BigInteger

The ID of the agent task to get consumed credits for.

Returns

Type Description
Decimal

The total Copilot credits consumed by the agent task.

See also