Skip to main content

Notifications

Announcements

No record found.

Business Central forum

Automated customer reminders

Posted on by 70

Hi,

Requirement:

Customer to be reminded of payment 10 and 3 days before due date through email.

Configuration done in Business Central :


1. Created reminder terms with two levels. first -10D in grace period and second -3D in grace period.

2. Assigned the reminder term to the customer.

Problem started here:


When i go to reminders screen and click on process-> create reminders and unselect the option "Only show overdue invoices"

(10 days before the invoice)

sometimes the invoices wont show as lines in the reminders.

sometimes the reminder will not be created at all.

Now this is a real problem because i plan to automate the customer reminders based on above terms using the scheduled jobs.

Categories:
  • Usman Naseer Profile Picture
    Usman Naseer 80 on at
    RE: Automated customer reminders

    It works for advance reminders. Now i want to keep sending reminders after each 7 days of past issued reminder until the balance is cleared. Do you have any suggestions to achieve this functionality.

  • Usman Naseer Profile Picture
    Usman Naseer 80 on at
    RE: Automated customer reminders

    Thanks for sharing the code.

  • Suggested answer
    tanveerk Profile Picture
    tanveerk 70 on at
    RE: Automated customer reminders

    The code is below:

    Reminder term code for customers which need to be reminded must be :'REMIND'

    This code is checking if an invoice which has remaining balance >0 and is due in 10 days.

    It then checks for all the contacts of that customer and sends reminder email to their email addresses. If you want to change the number of days search for          'if (days = 10) ' in the code and update it with number of days before the due date on which you want to send reminders to customers.

    For it to work SMTP setup should be working.

    If you are mentioning a email address other than the smtp configuration, give the smtp configured user access to the mailbox you are sending from.

    Finally, created a job queue that runs this everyday

    pastedimage1568010710012v1.png

    codeunit 50111 SendReminderEmails

    {

       // Customer Rewards Install Logic

       //  Subtype = Normal;

       var

           remindermanke: Codeunit "Reminder-Make";

           customer: record Customer;

           customertotal: BigInteger;

           invoicestotal: BigInteger;

           invoice: record "Sales Invoice Header";

           invoice2: record "Sales Invoice Header";

           currentinvoice: record "Sales Invoice Header";

           duedate: Date;

           datetoday: Date;

           days: BigInteger;

           email: Codeunit "SMTP Mail";

           optionName: Option;

           typeinvoice: Option;

           reminderdate: Date;

           reminder2date: Date;

           emailBody: text;

           contacts: Record Contact;

           salesLines: Record "Sales Invoice Line";

           InvAmt: Decimal;

           UsedCurrency: Text;

           company: record "General Ledger Setup";

           InvoiceCurrency: text;

           FinalCurrency: Text;

           // trigger OnRun()

           dateCurrent: Date;

           contactbusinessrelation: Record "Contact Business Relation";

           contactscount: Integer;

           salesHeader: record "Sales Header";

       trigger OnRun()

       begin

           datetoday := Today();

           dateCurrent := datetoday;

           customer.SetFilter("Reminder Terms Code", 'REMIND');

           if customer.FindSet()

          then begin

               customertotal := customer.Count();

               repeat

                   invoice.SetFilter("Bill-to Customer No.", customer."No.");

                   if invoice.FindSet() then begin

                       repeat

                           duedate := invoice."Due Date";

                           if (duedate <> 0D)

                           then begin

                               invoice.CalcFields("Amount Including VAT", "Remaining Amount");

                               if (invoice."Remaining Amount" > 0) then begin

                                   days := duedate - dateCurrent;

                                   if (invoice."Currency Code" = '')

                                   then begin

                                       company.FindSet();

                                       FinalCurrency := company."LCY Code";

                                   end

                                   else begin

                                       FinalCurrency := invoice."Currency Code";

                                   END;

                                   if (days = 10)

                                   then begin

                                       if (contactbusinessrelation.FindSet()) then begin

                                           contactbusinessrelation.SetFilter("No.", customer."No.");

                                           contacts.SetFilter("Company No.", contactbusinessrelation."Contact No.");

                                           contacts.SetFilter("E-Mail", '<>%1', '');

                                           if contacts.FindSet then begin

                                               emailBody := '<h3>TO MESSRS:  ' + invoice."Sell-to Customer Name" + '</h3>' +

                                                        'ATT : ACCOUNTING DEPARTMENT ' +

                                                        '</br> </h3><h2>Friendly Reminder</h2>' +

                                                        ' <hr>' +

                                                        '</br>Please make sure the following invoice is paid in due time.' +

                                                        '</br></br><strong>' + FinalCurrency + ' ' + FORMAT(invoice."Amount Including VAT", 0, 3) +

                                                       ' for our invoice no. ' + invoice."No." + ' due on ' + Format(invoice."Due Date", 0, '<Month Text> <Closing><Day>, <Year4>') +

                                                         '</strong></br></br>Please disregard this email if this invoice has already been paid. </br>' +

                                                       '</br><hr></br>Many thanks in advance for your cooperation,' +

                                                         '</br>Very best regards,' +

                                                        '</br></br>Financial Department' +

                                                       '</br>Your company name' +

                                                        '</br>' + Format(Today, 0, '<Month Text> <Closing><Day>, <Year4>');

                                               email.CreateMessage('Sender Name', Sender Email(Should have access to it), '', 'Reminder for approaching due date ', emailBody, true);

                                               repeat

                                                   if contacts."E-Mail" <> '' then

                                                       email.AddRecipients(contacts."E-Mail");

                                               until contacts.Next = 0;

                                               email.AddBCC(BCC EMAIL ADDRESSS);

                                               email.Send();

                                           END;

                                       end;

                                   END;

                               End;

                           END;

                       until invoice.Next = 0;

                   end;

               until customer.Next = 0;

           END;

       end;

    }

  • Usman Naseer Profile Picture
    Usman Naseer 80 on at
    RE: Automated customer reminders

    Hi, can you please share the code for the code unit you have created ?

  • Suggested answer
    tanveerk Profile Picture
    tanveerk 70 on at
    RE: Automated customer reminders

    Created custom code unit that sends mail using codeunit 400.

    Scheduled it to run on recurring basis.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans