Skip to content

Agent Message and Task - Fix modifying functions to only modify the target values#7618

Open
BazookaMusic wants to merge 2 commits intomainfrom
private/sodragon/agent-task-pk-overloads
Open

Agent Message and Task - Fix modifying functions to only modify the target values#7618
BazookaMusic wants to merge 2 commits intomainfrom
private/sodragon/agent-task-pk-overloads

Conversation

@BazookaMusic
Copy link
Copy Markdown
Contributor

@BazookaMusic BazookaMusic commented Apr 9, 2026

Summary

The "Agent Message" and "Agent Task" codeunits had a major issue in the way their API worked. Methods which modified field values were using a var record parameter. What this means is that if the passed in record had modified fields and somebody calls for example SetStatusToSent, the code will attempt to modify all fields including the status.

Fix
Obsolete these methods and replace them with methods that take the PK and the new value. These will refetch the latest value, modify the field and then modify. They return the modified record as a return value.

Work Item(s)

Fixes AB#629278

- Modify methods to Get a fresh record before modifying to avoid
  overwriting unrelated fields
- Add PK-based overloads (TaskID/MessageID/AgentTaskID) to public
  and impl codeunits
- Obsolete old record-based write overloads with #if not CLEAN30
- Add documentation for read-only record overloads noting the record
  is not re-retrieved
- Replace record-based UpdateText/SetStatusToSent/StopTask/RestartTask/
  SetStatusToReady calls with PK-based overloads in AgentTaskMessageCard,
  SOAEmailMessage, SOASendReplies, and AgentTaskManagementTest
@BazookaMusic BazookaMusic requested a review from a team as a code owner April 9, 2026 14:43
@github-actions github-actions bot added this to the Version 29.0 milestone Apr 9, 2026
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AL Documentation Audit

Documentation gaps were detected in the following apps:

  • Agent-Test: 0% documentation coverage
  • Agent: 0% documentation coverage

To generate documentation, run /al-docs init or /al-docs update using GitHub Copilot CLI or Claude Code.
This review is for awareness to help keep documentation in sync with code changes. It is okay to dismiss this request.

UpdateText(AgentTaskMessage, NewMessageText);
end;

procedure UpdateText(var AgentTaskMessage: Record "Agent Task Message"; NewMessageText: Text)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method changed behavior, should we have a unit test for it to ensure we are not modifying all fields, but only the content?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants