Skip to main content

Notifications

Announcements

No record found.

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.

Posted on by 60

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
    Nitin Verma 21,091 Super User 2024 Season 1 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;

    }

  • 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

  • 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
    Nitin Verma 21,091 Super User 2024 Season 1 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

  • 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
    Nitin Verma 21,091 Super User 2024 Season 1 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans