Skip to content

[SOA] Show Cc recipients on email messages - #10247

Open
attilatoury wants to merge 6 commits into
mainfrom
private/attilatoury/fix-soa-cc-visibility
Open

[SOA] Show Cc recipients on email messages#10247
attilatoury wants to merge 6 commits into
mainfrom
private/attilatoury/fix-soa-cc-visibility

Conversation

@attilatoury

@attilatoury attilatoury commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What & why

Sales Order Agent email cards did not show Cc recipients, so reviewers could not see everyone included in incoming and outgoing correspondence.

This change adds the standard read-only, Additional-importance Cc field to the email details. It resolves the complete Cc list from the original inbox email for both incoming messages and their outgoing replies, using the same semicolon-separated formatting as the Business Central Email Viewer. The field remains present but blank when there are no Cc recipients.

Linked work

Fixes AB#632233

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

  • git diff --check passed, and the committed diff contains only the two intended Sales Order Agent files.
  • VS Code diagnostics report no errors in the changed files.
  • Direct compilation with CodeCop, AppSourceCop, and UICop was attempted against fresh 29.0 symbols from the running NAV master service. It is blocked by pre-existing baseline mismatches outside this change: missing Manual Agent Task Creation Type/IAgentManualTaskCreation symbols and the missing Contact List.OnBeforeFindRecord event introduced by another current-main change.
  • No tests were added in this GitHub PR because the Sales Order Agent internal test app remains in the NAV repository and cannot be included in the same GitHub PR. CI remains authoritative for the current-main baseline build.

Risk & compatibility

Low. The change is read-only and does not alter email creation, recipient selection, sending, or stored data. Missing inbox/message records produce a blank Cc value. Multiple recipients use the standard semicolon-separated Email Viewer format. Very long lists follow the existing Business Central Email Viewer behavior; no separate recipient-list UX is introduced by this minimal fix.

Fixes AB#632233

@attilatoury
attilatoury requested a review from a team August 14, 2026 07:34
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Team: SCM GitHub request for SCM area labels Aug 14, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 14, 2026
Comment thread src/Apps/W1/SalesOrderAgent/app/src/Integration/SOATaskMessage.Codeunit.al Outdated
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Agentic PR Review - Round 1

Recommendation: Accept

What this PR does

This fixes the Sales Order Agent Cc visibility bug by adding a read-only Cc field to the email details page and loading it from the original inbox email. The code resolves outgoing messages back to their input message, uses the same semicolon format as the Email Viewer, and returns blank when the source email cannot be found. The change is read-only and does not change recipient selection or email sending.

Suggestions

None.

Risk assessment and necessity

Risk: The regression surface is limited to the Sales Order Agent email card. The new field reads recipients from Email Inbox and Email Message; it does not write data, change reply creation, or affect posting. There is no BaseApp event or publisher dependency.

Necessity: The linked bug has a clear repro: reviewers cannot see Cc recipients in the incoming or outgoing SOA email cards, even though the email thread includes them. The scoped UI addition is justified and matches the existing Email Viewer display pattern.


[AI-PR-REVIEW] version=1 promptVersion=2 system=github pr=10247 round=1 by=alexei-dobriansky at=2026-08-14T08:43:51Z lastSha=135457c92d999efbc4c8e3e884256de78361efdc reviewKey=na suggestions=

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

Comment thread src/Apps/W1/SalesOrderAgent/app/src/Integration/SOATaskMessage.Codeunit.al Outdated
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Agentic PR Review - Round 2

Recommendation: Accept

What this PR does

The new commit only changes SOATaskMessage.Codeunit.al to build the Cc recipient string with TextBuilder instead of repeated Text concatenation. The net PR diff still adds a read-only Cc field on SOA Email Message and resolves Cc recipients from the original inbox email for both input messages and output replies. The TextBuilder loop keeps the same semicolon-separated format as EmailMessageImpl.GetRecipientsAsText, so this round does not change the feature behavior.

Status of previous suggestions

No previous suggestions.

New observations (commits since round 1)

None - the new commit is a mechanical TextBuilder replacement and does not introduce a new correctness, data-integrity, security, concurrency, or compatibility issue.

Risk assessment and necessity

Risk: The round-2 change is limited to src/Apps/W1/SalesOrderAgent/app/src/Integration/SOATaskMessage.Codeunit.al lines 133 and 153-160 in the current diff. It preserves the same Cc recipient order and ; separator, does not write data, and does not affect email sending or recipient selection. git diff --check passed for the frozen PR diff.

Necessity: The linked bug describes missing Cc visibility on SOA email review screens. The PR remains a narrow UI/read-only fix for that problem, and the new commit improves string construction without changing the intended scope.


[AI-PR-REVIEW] version=1 promptVersion=2 system=github pr=10247 round=2 by=alexei-dobriansky at=2026-08-20T18:20:30Z lastSha=dfeadde9df433645220f1c09f48d4202022211ff reviewKey=94481e43e11c8aeb5fb00b577855675823c1175540f8597a3172cf09607bcb68 suggestions=empty parentRound=1

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

auto-merge was automatically disabled August 24, 2026 08:37

Pull request was closed

@attilatoury attilatoury reopened this Aug 24, 2026

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.

Approved with suggestions.

S1: For output messages, the displayed Cc list is read from the raw inbound email, while the send path excludes the original sender and agent mailbox and deduplicates Cc recipients against To recipients. Please align the displayed outgoing Cc list with the normalized recipients that are actually sent.

S2: Add or link companion Sales Order Agent tests covering incoming and outgoing Cc display, multiple recipients, and the exclusion/deduplication case.

S3: Consider adding and using a key on SOA Email for ("Task ID", "Task Message ID"), because the new lookup runs on every page refresh and no existing key supports that filter pair.

@attilatoury

Copy link
Copy Markdown
Contributor Author

alexei-dobriansky Predrag Maricic (@PredragMaricic) The addressed feedback is now in 34567c6b1e; please re-review when convenient.

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 4

Recommendation: Accept

What this PR does

The new commit aligns the Cc value shown for output replies with the same recipient-building path used when a mapped reply is sent. It adds a lookup key on SOA Email, exposes an internal try wrapper for mapped-reply Cc calculation, and has SOA Task Message use that mapped Cc list before falling back to the source message. The changed path remains read-only and does not change email sending, stored data, or the review flow.

Status of previous suggestions

No previous suggestions.

New observations (commits since round 3)

None - the new commit keeps the display path aligned with the mapped-reply send logic, including recipient filtering and de-duplication. The added key matches the existing Task ID + Task Message ID lookup, and git diff --check passed for the current net PR diff.

Risk assessment and necessity

Risk: The regression surface is limited to the Sales Order Agent email details card for output messages and to the new SOA Email lookup key. The code reuses the same mapped-recipient calculation as send; if that cannot resolve the source email or account, the display falls back to the existing source-Cc path instead of changing send behavior. There is no BaseApp event or publisher dependency.

Necessity: The reported bug is a visibility gap: Cc recipients can already be part of the mail flow, but the Sales Order Agent card did not show them. The latest commit is necessary because mapped replies can filter or move recipients compared with the raw inbound Cc list, so the card should show the Cc list that matches the sent reply.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10247 round=4 by=alexei-dobriansky at=2026-09-01T18:17:30Z lastSha=34567c6b1ec05130c8ff41b9f51038d2ce6dfcb7 reviewKey=62cb4b7aba3a00d6fe225ae1504c13b0cb946ee2d763b602b6c538e98e75ca9b suggestions=none parentRound=3

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

@attilatoury attilatoury closed this Sep 7, 2026
auto-merge was automatically disabled September 7, 2026 07:52

Pull request was closed

@attilatoury attilatoury reopened this Sep 7, 2026
@github-actions github-actions Bot added Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration and removed Team: SCM GitHub request for SCM area labels Sep 7, 2026
VolodySyn
VolodySyn previously approved these changes Sep 7, 2026
@attilatoury

Copy link
Copy Markdown
Contributor Author

PR approved but waiting for the private deployment from https://dynamicssmb2.visualstudio.com/Dynamics%20SMB/_git/NAV/pullrequest/253790 to be ready for manual testing. The previous one had failed

Copilot AI left a comment

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.

🟡 Changes recommended

The mapped-reply Cc behavior appears inconsistent with the stated “complete inbox Cc” requirement, and the new Task/Message index should be actively used to avoid inefficient lookups.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

src/Apps/W1/SalesOrderAgent/app/src/Integration/SOATaskMessage.Codeunit.al:146

  • SOAEmail is filtered by "Task ID"/"Task Message ID" and this PR adds Key3 for that lookup, but the query here never sets the current key. Without SetCurrentKey("Task ID", "Task Message ID"), the server may still use the clustered key ("Email Inbox ID") which can degrade performance as the table grows.
        SOAEmail.SetLoadFields("Email Inbox ID");
        SOAEmail.SetRange("Task ID", SourceAgentTaskMessage."Task ID");
        SOAEmail.SetRange("Task Message ID", SourceAgentTaskMessage.ID);
        if not SOAEmail.FindFirst() then
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +135 to +141
SourceAgentTaskMessage := AgentTaskMessage;
if AgentTaskMessage.Type = AgentTaskMessage.Type::Output then begin
if not SourceAgentTaskMessage.Get(AgentTaskMessage."Task ID", AgentTaskMessage."Input Message ID") then
exit('');
if SOASendReply.TryGetMappedReplyCcRecipients(SourceAgentTaskMessage, CcRecipients, IsMappedReply) and IsMappedReply then
exit(RecipientsToText(CcRecipients));
end;
Declare read-only Email Inbox permissions in SOA Task Message and SOA Send Reply. Fixes the license Read error when opening incoming/outgoing email cards from the agent timeline, including mapped-contact recipient resolution.

Validated full Sales Order Agent compilation with CodeCop and UICop: no errors or warnings; four AW0006 informational page diagnostics. Verified both declarations in compiled metadata. Private ORGTIE runtime retest pending.
exit(true);
end;

internal procedure GetMessageCcRecipients(AgentTaskMessage: Record "Agent Task Message"): 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.

$\textbf{🟡\ Medium\ Severity\ —\ Security}$

GetMessageCcRecipients (SOATaskMessage.Codeunit.al) uses the codeunit's new Permissions = tabledata "Email Inbox" = r; grant to read CC recipients from Email Inbox/Email Message and, for mapped replies, delegates to SOA Send Reply.TryGetMappedReplyCcRecipients, without re-running SOA Send Reply's existing ValidateMessageAccess check (Agent User Security ID / authorized-user check) before surfacing that data. Access = Internal and the tabledata permission grant are API/data-access hygiene, not an authorization boundary; if this preview path can be reached for a message the current user does not otherwise own, the CC addresses are disclosed without the same authorization check the actual send path enforces. Recommend running the same authorization check (or documenting why the page's existing record-level access control already covers this) before returning CC data.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.41.6

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

Labels

AL: Apps (W1) Add-on apps for W1 Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants