Skip to content

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

Open
attilatoury wants to merge 1 commit into
mainfrom
private/attilatoury/fix-soa-cc-visibility
Open

[SOA] Show Cc recipients on email messages#10247
attilatoury wants to merge 1 commit 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.

@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 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
EmailMessage: Codeunit "Email Message";
CcRecipients: List of [Text];
CcRecipient: Text;
CcRecipientsText: 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\ —\ Performance}$

GetMessageCcRecipients builds the CC list by repeatedly appending to a Text value inside the foreach loop. Use a TextBuilder and convert once after the loop to avoid reallocating the result for every recipient.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

        CcRecipientsTextBuilder: TextBuilder;
    begin
        SourceAgentTaskMessage := AgentTaskMessage;
        if AgentTaskMessage.Type = AgentTaskMessage.Type::Output then
            if not SourceAgentTaskMessage.Get(AgentTaskMessage."Task ID", AgentTaskMessage."Input Message ID") then
                exit('');

        SOAEmail.SetLoadFields("Email Inbox ID");
        SOAEmail.SetRange("Task ID", SourceAgentTaskMessage."Task ID");
        SOAEmail.SetRange("Task Message ID", SourceAgentTaskMessage.ID);
        if not SOAEmail.FindFirst() then
            exit('');

        EmailInbox.SetLoadFields("Message Id");
        if not EmailInbox.Get(SOAEmail."Email Inbox ID") then
            exit('');
        if not EmailMessage.Get(EmailInbox."Message Id") then
            exit('');

        EmailMessage.GetRecipients(Enum::"Email Recipient Type"::Cc, CcRecipients);
        foreach CcRecipient in CcRecipients do begin
            if CcRecipientsTextBuilder.Length() > 0 then
                CcRecipientsTextBuilder.Append(';');
            CcRecipientsTextBuilder.Append(CcRecipient);
        end;

        exit(CcRecipientsTextBuilder.ToText());

Knowledge:

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

@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=

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 SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants