[W1][Codeunit][4509][Email - Outlook API Helper] OnBeforeInsert event in CreateEmailInboxFromJsonObject exposing the source JSON payload

Open Beginner friendly
#10,781 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active

Research direction

Open Codeunit 4509 "Email - Outlook API Helper" and locate the local procedure CreateEmailInboxFromJsonObject. Start at the existing EmailInbox.Insert() call and add the requested integration event immediately before it, passing the Email Inbox record by var and the source EmailJsonObject. Done means subscribers can enrich the record or inspect the original JSON before insertion.

Written by the indexing model from the issue text.

Description

Approved event-request ext-ready-to-implement Team: Integrations
Why do you need this change?

When emails are retrieved through the Email Connector v4 RetrieveEmails flow, CreateEmailInboxFromJsonObject parses the Microsoft Graph message JSON but only maps a subset of fields onto the Email Inbox record. Notably, the recipient collections that Graph returns (toRecipients, ccRecipients, bccRecipients) are not transferred to the created Email Message/Email Inbox — the message is built with EmailMessage.Create('', Subject, Body, HTMLBody, true), so GetRecipients is always empty for retrieved mail.

As a result, any app that logs retrieved emails cannot obtain the actual To/Cc recipients of a retrieved message. There is currently no seam to recover them: the connector codeunits are Access = Internal, the OAuth token is a private [NonDebuggable] SecretText, and no event is raised around the insert. The only workaround today is to independently re-query Microsoft Graph with a separate app registration, which forces every customer to create and consent to an Azure AD app purely to read data Business Central already fetched.

An integration event that exposes the raw source JSON just before the Email Inbox record is inserted would let subscribers read any property Graph returned (recipients, importance, categories, internetMessageId, etc.) and/or enrich the Email Inbox record — without Microsoft having to add every field to the standard mapping, and without customers standing up a duplicate Graph integration. This is a general-purpose extensibility point that benefits any partner building mail-logging, archiving, or CRM scenarios on top of the email retrieval feature.

Describe the request

Please add an OnBefore-insert integration event in Codeunit 4509 "Email - Outlook API Helper", in the local procedure CreateEmailInboxFromJsonObject, raised immediately before EmailInbox.Insert();. The event should pass the Email Inbox record by var (so subscribers can set additional/custom fields before it is persisted) and the source EmailJsonObject for the message (so subscribers can read any property returned by Graph, including the recipient arrays that are not currently mapped).

This is a "before we insert a line to update specific fields" hook, which is listed as a valid use in Types of events for extensibility. It is a standard IntegrationEvent (not an IsHandled/skip event) — it only notifies and allows enrichment; it does not override or suppress the insert.

Provide an implementation (optional)
  • I will provide the implementation for this extensibility request
Dominant language
AL
Stars
683
Forks
459
Avg merge
2d 20h
Merged PRs (30d)
621

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/BCApps

All issues in microsoft/BCApps

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.