I tried to change the Subject of Notification email as below
codeunit 50100 MyNotificationDispatcher
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Notification Entry Dispatcher", 'OnBeforeCreateMailAndDispatch', '', true, true)]
local procedure OnBeforeCreateMailAndDispatch(var Notification: Record "Notification Entry")
var
Mail: Record Mail;
begin
// Get the mail record associated with the notification
if Mail.Find('-' + Notification."Notification ID") then
begin
// Modify the subject of the mail record
Mail.Subject := 'New Subject';
Mail.Modify;
end;
end;
}
But the Visual Code does not under Notification and Record Mail
Would you like help me to point what I was wrong in the Code.
I also tried another code form link:
But after publish, the subject is not changed as I am expecting
codeunit 50100 MyNotificationDispatcher
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Document-Mailing", 'OnBeforeGetEmailSubject', '', false, false)]
local procedure OnBeforeGetEmailSubject(PostedDocNo: Code[20]; EmailDocumentName: Text[250]; ReportUsage: Integer; var EmailSubject: Text[250]; var IsHandled: Boolean);
begin
EmailSubject := 'PO Info - New Email Subject';
if ReportUsage = 6 then begin
EmailSubject := '6 - New Email Subject';
IsHandled := true;
end;
end;
}
Thanks