diff --git a/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al b/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al
index 156bb9e67c..41e91a9baa 100644
--- a/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al
+++ b/src/System Application/App/Agent/Interaction/AgentTask.Codeunit.al
@@ -272,6 +272,32 @@ codeunit 4303 "Agent Task"
exit(AgentTaskImpl.GetDetailsForAgentTaskLogEntry(AgentTaskLogEntry));
end;
+ ///
+ /// Gets the model ID of the agent task.
+ ///
+ /// The ID of the agent task.
+ /// The model ID of the agent task. Must be valid value from Agent Model table.
+ procedure GetModelId(AgentTaskID: BigInteger): Code[30]
+ var
+ AgentTaskImpl: Codeunit "Agent Task Impl.";
+ begin
+ FeatureAccessManagement.AgentManagementAllowed(true);
+ exit(AgentTaskImpl.GetModelId(AgentTaskID));
+ end;
+
+ ///
+ /// Gets the model name of the agent task.
+ ///
+ /// The ID of the agent task.
+ /// The model name of the agent task.
+ procedure GetModelName(AgentTaskID: BigInteger): Text[70]
+ var
+ AgentTaskImpl: Codeunit "Agent Task Impl.";
+ begin
+ FeatureAccessManagement.AgentManagementAllowed(true);
+ exit(AgentTaskImpl.GetModelName(AgentTaskID));
+ end;
+
var
FeatureAccessManagement: Codeunit "Feature Access Management";
diff --git a/src/System Application/App/Agent/Interaction/AgentTaskBuilder.Codeunit.al b/src/System Application/App/Agent/Interaction/AgentTaskBuilder.Codeunit.al
index c403f63c74..77c79f57b5 100644
--- a/src/System Application/App/Agent/Interaction/AgentTaskBuilder.Codeunit.al
+++ b/src/System Application/App/Agent/Interaction/AgentTaskBuilder.Codeunit.al
@@ -62,7 +62,6 @@ codeunit 4315 "Agent Task Builder"
/// Specifies whether a message is required, default is true.
/// Agent task that was created.
/// The builder keeps the state, do not reuse the same instance of the builder to create multiple tasks.
- [Scope('OnPrem')]
procedure Create(SetTaskStatusToReady: Boolean; RequiresMessage: Boolean): Record "Agent Task"
begin
FeatureAccessManagement.AgentTaskManagementPreviewEnabled(true);
@@ -81,6 +80,20 @@ codeunit 4315 "Agent Task Builder"
exit(AgentTaskBuilderImpl.GetAgentTaskMessageCreated());
end;
+ ///
+ /// Set the model ID that will be used to process the task.
+ /// If the model ID is not set, the model from the agent will be used, if any.
+ /// If the agent does not have a model, the default model will be used.
+ ///
+ /// The model ID of the task. This field is used to connect to external systems, like Message ID for emails.
+ /// This instance of the Agent Task Builder.
+ procedure SetModelId(ModelId: Code[30]): codeunit "Agent Task Builder"
+ begin
+ FeatureAccessManagement.AgentManagementAllowed(true);
+ AgentTaskBuilderImpl.SetModelId(ModelId);
+ exit(this);
+ end;
+
///
/// Set the external ID of the task.
///
diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskBuilderImpl.Codeunit.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskBuilderImpl.Codeunit.al
index 4fdd5e97fe..639aefd45b 100644
--- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskBuilderImpl.Codeunit.al
+++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskBuilderImpl.Codeunit.al
@@ -20,6 +20,7 @@ codeunit 4310 "Agent Task Builder Impl."
GlobalAgentUserSecurityId: Guid;
GlobalTaskTitle: Text[150];
GlobalExternalID: Text[2048];
+ GlobalModelId: Code[30];
GlobalBillingContext: Enum "Agent Task Billing Context";
[Scope('OnPrem')]
@@ -40,7 +41,7 @@ codeunit 4310 "Agent Task Builder Impl."
VerifyMandatoryFieldsSet();
VerifyTaskCanBeCreated(RequiresMessage);
- AgentTaskImpl.CreateTask(GlobalAgentUserSecurityId, GlobalTaskTitle, GlobalExternalID, GlobalBillingContext, AgentTaskRecord);
+ AgentTaskImpl.CreateTask(GlobalAgentUserSecurityId, GlobalTaskTitle, GlobalExternalID, GlobalBillingContext, GlobalModelId, AgentTaskRecord);
if MessageSet then begin
GlobalAgentTaskMessageBuilder.SetAgentTask(AgentTaskRecord);
GlobalAgentTaskMessageBuilder.Create(false);
@@ -65,6 +66,13 @@ codeunit 4310 "Agent Task Builder Impl."
exit(this);
end;
+ [Scope('OnPrem')]
+ procedure SetModelId(ModelId: Code[30]): codeunit "Agent Task Builder Impl."
+ begin
+ GlobalModelId := ModelId;
+ exit(this);
+ end;
+
[Scope('OnPrem')]
procedure SetBillingContext(BillingContext: Enum "Agent Task Billing Context"): codeunit "Agent Task Builder Impl."
begin
diff --git a/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al b/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al
index 80daef7a6e..f374e98310 100644
--- a/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al
+++ b/src/System Application/App/Agent/Interaction/Internal/AgentTaskImpl.Codeunit.al
@@ -43,7 +43,7 @@ codeunit 4300 "Agent Task Impl."
Page.Run(Page::"Agent Task Log Entry List", AgentTaskLogEntry);
end;
- procedure CreateTask(AgentUserSecurityID: Guid; TaskTitle: Text[150]; ExternalID: Text[2048]; BillingContext: Enum "Agent Task Billing Context"; var NewAgentTask: Record "Agent Task")
+ procedure CreateTask(AgentUserSecurityID: Guid; TaskTitle: Text[150]; ExternalID: Text[2048]; BillingContext: Enum "Agent Task Billing Context"; ModelId: Code[30]; var NewAgentTask: Record "Agent Task")
begin
NewAgentTask."Agent User Security ID" := AgentUserSecurityID;
NewAgentTask."Created By" := UserSecurityId();
@@ -51,6 +51,7 @@ codeunit 4300 "Agent Task Impl."
NewAgentTask."Needs Attention" := false;
NewAgentTask.Status := NewAgentTask.Status::Paused;
NewAgentTask."External ID" := ExternalID;
+ NewAgentTask."Model ID" := ModelId;
NewAgentTask."Billing Context" := BillingContext;
NewAgentTask.Insert();
end;
@@ -227,6 +228,24 @@ codeunit 4300 "Agent Task Impl."
exit(false);
end;
+ procedure GetModelId(TaskId: BigInteger): Code[30]
+ var
+ AgentTaskRecord: Record "Agent Task";
+ begin
+ AgentTaskRecord.Get(TaskId);
+ exit(AgentTaskRecord."Model ID")
+ end;
+
+ procedure GetModelName(TaskId: BigInteger): Text[70]
+ var
+ AgentTaskRecord: Record "Agent Task";
+ begin
+ AgentTaskRecord.Get(TaskId);
+ AgentTaskRecord.CalcFields("Model Name");
+ exit(AgentTaskRecord."Model Name");
+ end;
+
+
[EventSubscriber(ObjectType::Codeunit, Codeunit::"System Action Triggers", GetAgentTaskMessagePageId, '', true, true)]
local procedure OnGetAgentTaskMessagePageId(var PageId: Integer)
begin