web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Send Alert to mail for New Vendor Creation

(2) ShareShare
ReportReport
Posted on by 208

Hi,

I have a query on How to trigger an alert to mail when a new vendor card is created?

My mail body should have : 

Message: New Vendor card is created.

Table body:  should have these fields , 1) account code 2)Name 3) date of creation 4)Who created the record

Please need help in this how can be done in Al code 

Thankyou.

  • Mohana Yadav Profile Picture
    61,248 Super User 2026 Season 2 on at

    What did you try and what issue are you facing?

  • NAV_with_Narang Profile Picture
    2,410 Moderator on at

    Since your aim is to write a suitable AL code to send Emails from BC, you can refer the below link

    businesscentralgeek.com/5-ways-to-send-an-email-in-business-central

    However, I would suggest use Power Automate instead of writing code in AL (if the customer has a license for PA).

    Sending an email every time some field is modified on BC on a vendor card, that can turn out inefficient or result into a lot of spam emails to someone. I'd suggest place the email SEND option when the record gets modified AND the vendor card is closed

  • Dividutt Profile Picture
    208 on at

    When I am creating an new vendor card

    Mail not getting triggered, how can I show message when I create new vendor card is there any trigger event?

  • Verified answer
    Mohana Yadav Profile Picture
    61,248 Super User 2026 Season 2 on at

    where did you write code?

    You have to use OnInsert triggers but you wont have other data like Name etc. by that time

  • Muhammad Faizan Subhani Profile Picture
    34 on at

    You can use Power Automate to create a workflow to send emails.

  • Dividutt Profile Picture
    208 on at

    I have no problem in sending mail, but I have to sent mail only when I create a new vendor card so

    This is code I tried is there any modifications needed?

    codeunit 50132 "Alert for New Vendor Creation"

    {

        [EventSubscriber(ObjectType::Table, Database::Vendor, 'OnAfterModifyEvent', '', true, true)]

        procedure AlertVendor(var Rec: Record Vendor; xRec: Record Vendor)

        var

            rec_Vendor: Record Vendor;

        begin

            

            if rec_Vendor.FindSet() then

                repeat

                 Message('%1',rec_Vendor."No.")

    InsertIntotable (rec_Vendor)

                until rec_Vendor.Next() = 0;

        end;

        procedure InsertIntoTable(rec_Vendor: Record Vendor)

        var

            rec_AlertNewVendor: Record "Alert New Vendor Creation";

        begin

            rec_AlertNewVendor.Init();

            rec_AlertNewVendor.No := CreateGuid();

            rec_AlertNewVendor."Account Code" := rec_Vendor."No.";

            rec_AlertNewVendor.Name := rec_Vendor.Name;

            rec_AlertNewVendor."Date of Creation" := rec_Vendor.SystemCreatedAt;

            rec_AlertNewVendor.User := rec_Vendor.SystemCreatedBy;

        end;

     

    So here when I create an new vendor card i need to get the message and table with these fields.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Seems that you have taken a wrong approach to create a new vendor. Can you tell me your requirement please?

    Thanks

  • Dividutt Profile Picture
    208 on at

    Hi Nithin Verma,

    When I created a new vendor card i want to show alert that new vendor card is created and wanted to show its No Name Date and User who created it.

    So just needed to how to trigger when new vendor is created.

  • Muhammad Faizan Subhani Profile Picture
    34 on at

    Hi Divi,

    Seems like you are subscribing the wrong event.  try to subscribe insert record events.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    You need to write your Event in custom codeunit like below and put your code inside Begin..End.

    [EventSubscriber(ObjectType::table, database::Vendor, 'OnAfterInsertEvent', '', false, false)]

       local procedure OnAfterInsertEventVendor(var Rec: Record Vendor)

       begin

       end;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 796 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 481 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 377 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans