Skip to main content

Notifications

Community site session details

Community site session details

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

While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

(0) ShareShare
ReportReport
Posted on by 29

Dear Team, 

Can you pls help me with my query? 

While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

Thanks 

Dileep G

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

    Hi,

    Can you try this?

    codeunit 50100 SendEmailGL

    {

       Permissions = tabledata "Gen. Journal Line" = R;

       [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterGLFinishPosting', '', false, false)]

       local procedure OnAfterGLFinishPostingGL(GLEntry: Record "G/L Entry"; var GenJnlLine: Record "Gen. Journal Line"; IsTransactionConsistent: Boolean; FirstTransactionNo: Integer; var GLRegister: Record "G/L Register"; var TempGLEntryBuf: Record "G/L Entry" temporary; var NextEntryNo: Integer; var NextTransactionNo: Integer)

       var

           EmailMessage: Codeunit "Email Message";

           Email: Codeunit Email;

           Recipients: List of [Text];

           gldetails: Record "Gen. Journal Line";

           main: Decimal;

           Subject: Text;

           Body: Text;

           GLPostedTitle: Label 'The GL Document %2 of Customer %1 has been posted.';

           GLPostedMsg: Label 'Dear Manager<br><br>The GL Document <font color="red"><strong>%2</strong></font> of Customer <strong>%1</strong> has been posted.<br> The total amount is <strong>%3</strong>. <br>The Posted Invoice Number is <strong>%4</strong>. <br> User ID <strong>%5</strong>';

       begin

           Recipients.Add('palindrome.nitin@gmail.com');

           Recipients.Add('nverma@conceptcloudservices.com');

           Subject := StrSubstNo(GLPostedTitle, GenJnlLine.SystemCreatedBy, GenJnlLine.Description);

           Body := StrSubstNo(GLPostedMsg, GenJnlLine."Amount (LCY)", GenJnlLine."Due Date");

           EmailMessage.Create(Recipients, Subject, Body, true);

           Email.Send(EmailMessage);

       end;

    }

  • Dileep Gopinathan Profile Picture
    29 on at
    RE: While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

    I am getting error for this code ., can you pls help me for this

  • Dileep Gopinathan Profile Picture
    29 on at
    RE: While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

    codeunit 80123 SendEmailGL

    {

       Permissions =

        tabledata "Gen. Journal Line" = R;

       [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterGLFinishPosting', '', false, false)]

       local procedure OnAfterGLFinishPosting(GLEntry: Record "G/L Entry"; var GenJnlLine: Record "Gen. Journal Line"; IsTransactionConsistent: Boolean; FirstTransactionNo: Integer; var GLRegister: Record "G/L Register"; var TempGLEntryBuf: Record "G/L Entry" temporary; var NextEntryNo: Integer; var NextTransactionNo: Integer)

    OnAfterPostGenJnlLine(GenJnlLine5, SuppressCommit, GenJnlPostLine, IsPosted, GenJournalLine);

       var

           //         //SmtpMailSetup: Record "SMTP Mail Setup";

           //         //Mail: Codeunit "SMTP Mail";

           EmailMessage: Codeunit "Email Message";

           Email: Codeunit Email;

           Recipients: List of [Text];

           gldetails: Record "Gen. Journal Line";

           main: Decimal;

           Subject: Text;

           Body: Text;

           GLPostedTitle: Label 'The GL Document %2 of Customer %1 has been posted.';

           GLPostedMsg: Label 'Dear Manager<br><br>The GL Document <font color="red"><strong>%2</strong></font> of Customer <strong>%1</strong> has been posted.<br> The total amount is <strong>%3</strong>. <br>The Posted Invoice Number is <strong>%4</strong>. <br> User ID <strong>%5</strong>';

       begin

           Recipients.Add('dileep.gopinathan@maglube.ae');

           Recipients.Add('it@maglube.ae');

           // GenJnlLine.CalcFields("Bal. VAT Amount (LCY)");

           // GenJnlLine.flowfiled

           //Main := gldetails.Amount;

           Subject := StrSubstNo(GLPostedTitle, GenJnlLine.SystemCreatedBy, GenJnlLine.Description);

           Body := StrSubstNo(GLPostedMsg, GenJnlLine."Amount (LCY)", GenJnlLine."Due Date");

           EmailMessage.Create(Recipients, Subject, Body, true);

           Email.Send(EmailMessage, Enum::"Email Scenario"::Default);

       end;

    }

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

    Yes you can convey your requirements to your developer to customise this for you

  • Dileep Gopinathan Profile Picture
    29 on at
    RE: While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

    Thanks for your quick reply, the Email notification process is how I can enable it.

    ----- Below process we are planning.

    1. Creation of New Boolean “Email notify” in the below pages

    a. Chart of Account

    b. Customer

    c. Vendor

    2. If the “Email Notify” Boolean is true, then System will send an auto email with the below details whenever the user will pass a Payment or receipt entry using the “Email notify” boolean true CL/Vendor/Customer

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: While creating the Payment or receipt entry for some particular GL or customer account, I need to send one email notification to the employees.

    Hi,

    You need to customise the solution to achieve this

    Thanks

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,206 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,968 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans