RE: Send Alert to mail for New Vendor Creation
This is my final code, is this correct?
When I update again name field the name is getting triggered so I don't want this, mail should be triggered only once,
So is there any other event where I can maintain that?
codeunit 50132 "Alert for New Vendor Creation"
{
var
cdu_CommonHelper: Codeunit "Common Helper";
[EventSubscriber(ObjectType::Table, Database::Vendor, 'OnAfterValidateEvent', 'Name', true, true)]
procedure AlertVendor(var Rec: Record Vendor)
var
rec_Vendor: Record Vendor;
begin
rec_Vendor.SetRange("No.", Rec."No.");
if rec_Vendor.FindSet() then
repeat
if rec.Name <> '' then begin
//Message('%1', rec_Vendor.Name);
InsertIntoTable(rec_Vendor);
SendEmail();
end;
until rec_Vendor.Next() = 0;
end;