I created a custom codeunit to subscribe to OnAfterWhseActivLineInsert so I can send an email notification if certain criteria match.
The emails are not sending and not sure why. This is what i found in azure app insights
codeunit 50400 EmailUsedPick
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Pick", 'OnAfterWhseActivLineInsert', '', false, false)]
local procedure OnAfterWhseActivLineInsert(var WarehouseActivityLine: Record "Warehouse Activity Line")
var
Customer: Record "Customer";
SalesHeader: Record "Sales Header";
SalesPerson: Record "Salesperson/Purchaser";
EmailMessage: Codeunit "Email Message";
Email: Codeunit Email;
Salesman: Text;
SalesmanName: Text;
CustomerName: Text;
Recipients: List of [Text];
Subject: Text;
Body: Text;
Title: Label 'PICK %1';
Msg: Label 'Used Part pick has been created
The Sales Document %1 for Customer %2 has been created.
Customer wants %3 - %4.
Bin Code is %5.
Salesman is %6';
begin
Customer.SetFilter("No.", WarehouseActivityLine."Destination No.");
if Customer.FindSet() then
CustomerName := Customer.Name;
SalesHeader.SetFilter("No.", WarehouseActivityLine."Source No.");
if SalesHeader.FindSet() then
Salesman := SalesHeader."Salesperson Code";
SalesPerson.SetFilter(Code, Salesman);
if SalesPerson.FindSet() then
SalesmanName := SalesPerson.Name;
if (WarehouseActivityLine."Source Document" = "Warehouse Activity Source Document"::"Sales Order") then
if (WarehouseActivityLine."Location Code" = 'KS') then
case (WarehouseActivityLine."Zone Code") of
'WHSE 5':
begin
Recipients.Add('***');
end;
'WHSE 9':
begin
Recipients.Add('***');
end;
'WHSE 10':
begin
Recipients.Add('***');
Recipients.Add('***');
end;
end;
if (WarehouseActivityLine."Bin Code" = 'SC - WHS B') then
Recipients.Add('***');
if (Recipients.Count > 0) then begin
Subject := StrSubstNo(Title, WarehouseActivityLine.Description);
Body := StrSubstNo(Msg, WarehouseActivityLine."Source No.", CustomerName, WarehouseActivityLine."Qty. (Base)", WarehouseActivityLine.Description, WarehouseActivityLine."Bin Code", SalesmanName);
EmailMessage.Create(Recipients, Subject, Body, true);
Email.Send(EmailMessage, Enum::"Email Scenario"::Notification);
end;
end;
}
Web Service Called (Outgoing): graph.microsoft.com/.../sendMail
aadTenantId
****
alAuthenticationMethod
AccessControlService
alHttpTimeout
00:01:40
alObjectId
4508
alObjectName
Email - Outlook API Client
alObjectType
CodeUnit
alStackTrace
"Email - Outlook API Client"(CodeUnit 4508).SendMailSingleRequest - Email - Outlook REST API by Microsoft
"Email - Outlook API Client"(CodeUnit 4508).SendEmail - Email - Outlook REST API by Microsoft
"Email - Outlook API Helper"(CodeUnit 4509).Send line 14 - Email - Outlook REST API by Microsoft
"Microsoft 365 Connector"(CodeUnit 4503).Send line 4 - Email - Microsoft 365 Connector by Microsoft
"Send Email"(CodeUnit 8890).OnRun(Trigger) line 5 - System Application by Microsoft
"Email Dispatcher"(CodeUnit 8888).SendEmail line 25 - System Application by Microsoft
"Email Dispatcher"(CodeUnit 8888).OnRun(Trigger) line 20 - System Application by Microsoft
"Email Impl"(CodeUnit 8900).Send line 41 - System Application by Microsoft
"Email Impl"(CodeUnit 8900).Send line 4 - System Application by Microsoft
"Email Impl"(CodeUnit 8900).Send line 7 - System Application by Microsoft
Email(CodeUnit 8901).Send line 2 - System Application by Microsoft
EmailUsedPick(CodeUnit 50400).OnAfterWhseActivLineInsert line 62 - AM Internal Extension by Addie
"Create Pick"(CodeUnit 7312).OnAfterWhseActivLineInsert(Event) line 2 - Base Application by Microsoft
"Create Pick"(CodeUnit 7312).CreateWhseDocLine line 42 - Base Application by Microsoft
"Create Pick"(CodeUnit 7312).CreateNewWhseDoc line 11 - Base Application by Microsoft
"Create Pick"(CodeUnit 7312).CreateWhseDocument line 85 - Base Application by Microsoft
"Whse.-Shipment - Create Pick"(Report 7318).OnPostReport(Trigger) line 8 - Base Application by Microsoft
"Warehouse Shipment Line"(Table 7321).CreatePickDocFromWhseShpt line 11 - Base Application by Microsoft
"Warehouse Shipment Line"(Table 7321).CreatePickDoc line 13 - Base Application by Microsoft
"Whse. Shipment Subform"(Page 7336).PickCreate line 12 - Base Application by Microsoft
"Warehouse Shipment"(Page 7335)."Create Pick - OnAction"(Trigger) line 3 - Base Application by Microsoft
companyName
****
component
Dynamics 365 Business Central Server
componentVersion
21.0.49939.51627
endpoint
https://graph.microsoft.com/v1.0/me/sendMail
environmentName
Production
environmentType
Production
eventId
RT0019
extensionId
e6328152-bb29-4664-9dae-3bc7eaae1fd8
extensionName
Email - Outlook REST API
extensionPublisher
Microsoft
extensionVersion
21.2.49946.50300
httpHeaders
{"Authorization":["Bearer "]}
httpMethod
POST
httpStatusCode
404
serverExecutionTime
00:00:00.0826007
sqlExecutes
0
sqlRowsRead
0
telemetrySchemaVersion
0.3
totalTime
00:00:00.0826007
Use ERROR with a text constant to improve telemetry details
aadTenantId
***
alCallerAppName
Base Application
alCallerAppVersion
21.2.49946.51746
alCallerAppVersionMajor
21
alCallerAppVersionMinor
2
alCallerPublisher
Microsoft
alCategory
FeatureTelemetry
alClientType
Web
alCompany
Abilene Machine LLC
alCountryCode
US
alDataClassification
SystemMetadata
alErrorCallStack
"Email - Outlook API Client"(CodeUnit 4508).ProcessErrorMessageResponse line 4 - Email - Outlook REST API by Microsoft\"Email - Outlook API Client"(CodeUnit 4508).SendMailSingleRequest - Email - Outlook REST API by Microsoft\"Email - Outlook API Client"(CodeUnit 4508).SendEmail - Email - Outlook REST API by Microsoft\"Email - Outlook API Helper"(CodeUnit 4509).Send line 14 - Email - Outlook REST API by Microsoft\"Microsoft 365 Connector"(CodeUnit 4503).Send line 4 - Email - Microsoft 365 Connector by Microsoft\"Send Email"(CodeUnit 8890).OnRun(Trigger) line 5 - System Application by Microsoft\"Email Dispatcher"(CodeUnit 8888).SendEmail line 25 - System Application by Microsoft\"Email Dispatcher"(CodeUnit 8888).OnRun(Trigger) line 20 - System Application by Microsoft\"Email Impl"(CodeUnit 8900).Send line 41 - System Application by Microsoft\"Email Impl"(CodeUnit 8900).Send line 4 - System Application by Microsoft\"Email Impl"(CodeUnit 8900).Send line 7 - System Application by Microsoft\Email(CodeUnit 8901).Send line 2 - System Application by Microsoft\EmailUsedPick(CodeUnit 50400).OnAfterWhseActivLineInsert line 62 - AM Internal Extension by Addie\"Create Pick"(CodeUnit 7312).OnAfterWhseActivLineInsert(Event) line 2 - Base Application by Microsoft\"Create Pick"(CodeUnit 7312).CreateWhseDocLine line 42 - Base Application by Microsoft\"Create Pick"(CodeUnit 7312).CreateNewWhseDoc line 11 - Base Application by Microsoft\"Create Pick"(CodeUnit 7312).CreateWhseDocument line 85 - Base Application by Microsoft\"Whse.-Shipment - Create Pick"(Report 7318).OnPostReport(Trigger) line 8 - Base Application by Microsoft\"Warehouse Shipment Line"(Table 7321).CreatePickDocFromWhseShpt line 11 - Base Application by Microsoft\"Warehouse Shipment Line"(Table 7321).CreatePickDoc line 13 - Base Application by Microsoft\"Whse. Shipment Subform"(Page 7336).PickCreate line 12 - Base Application by Microsoft\"Warehouse Shipment"(Page 7335)."Create Pick - OnAction"(Trigger) line 3 - Base Application by Microsoft\
alErrorText
Use ERROR with a text constant to improve telemetry details
alEventName
Failed to send email
alFeatureName
Emailing
alIsAdmin
No
alIsEvaluationCompany
No
alObjectId
8713
alObjectName
System Telemetry Logger
alObjectType
CodeUnit
alSubCategory
Error
alTenantLicenseState
Paid
alUserRole
SHIPPING AND RECEIVING - WMS
clientType
WebClient
companyName
Abilene Machine LLC
component
Dynamics 365 Business Central Server
componentVersion
21.0.49939.51627
environmentName
Production
environmentType
Production
eventId
AL0000CTP
extensionId
63ca2fa4-4f03-4f2b-a480-172fef340d3f
extensionName
System Application
extensionPublisher
Microsoft
extensionVersion
21.2.49946.51673
telemetrySchemaVersion
1.2
I assigned the scenario of notification which is what I used in my codeunit to use the shared mailbox account in BC
