SBX - Search With Button

SBX - Forum Post Title

Page filter

Microsoft Dynamics NAV Forum

Ashwini.123 asked a question on 15 May 2018 11:10 PM
My Badges

Question Status

Verified

Hi Experts,

I need to send mail based on customer due date if one customer having multiple line with same due date i need send a mail only 1 time but unfortunately its sending multiple time if 2 record with same duedate its sending mail for two time i dont want to send two time,please tell me how to put the filter for that.

Thank you

Reply
RockWith NAV responded on 15 May 2018 11:38 PM
My Badges
Suggested Answer

Can you please show us the code that you wrote?

Reply
Ashwini.123 responded on 15 May 2018 11:55 PM
My Badges

Hi

EmailUser.RESET;

  customerLedgerTable.RESET;

  customerLedgerTable.SETRANGE("Customer No.",EmailUser.No);

  IF customerLedgerTable.FINDSET THEN REPEAT

     BEGIN

                     DueDate := customerLedgerTable.DueDate;

    End

// it will check the duedate equal to today date if true means it will send the mail

if Duedate = TODAY  THEN //here only i need to stop multiple time mail send for 1 customer same duedate

BEGIN

SMTP.send;

END;

Thank you

Reply
Chris D'silva responded on 16 May 2018 2:39 AM
My Badges
Suggested Answer

Hi,

You can create a boolean variable say Check in customer ledger entry if mail sent then enable the boolean variable.

If (Duedate = TODAY) AND (Check =FALSE) then

Check=TRUE;

//your code

Send mail

Reply
Olister Rumao responded on 16 May 2018 6:05 AM
My Badges
Verified Answer

Hi Ashwini.123,

You need to create variable say TempDateof type Date and write the following code.

EmailUser.RESET;

CustomerLedgerEntries.RESET;

CustomerLedgerEntries.SETRANGE("Customer No.",EmailUser.No);

CustomerLedgerEntries.SETCURRENTKEY(DueDate);

CustomerLedgerEntries.ASCENDING(True);

IF CustomerLedgerEntries.FINDFIRST THEN

REPEAT

IF TempDate<>CustomerLedgerEntries.DueDate THEN BEGIN

//Send Email

TempDate =  CustomerLedgerEntries.DueDate;

END

UNTIL CustomerLedgerEntries.NEXT=0;

Reply
Suresh Kulla responded on 16 May 2018 7:53 AM
Suggested Answer

Ashwini,

What you need is Loop through the customer table as main loop and inside the customer table loop check the customer ledger entries for that customer with Due Date greater then today and if you find a record then send the email, this way you will not send duplicate emails and you don't need any additional field or logic.

Reply
RockWith NAV responded on 16 May 2018 9:48 AM
My Badges
Suggested Answer

I believe you skipped one Important point. You want to send one email based on due date which is if repeating then it should send only one but for that respective customer right? If there are 4 same due date but have 2 different customers then there would be 2 email for that 2 Customers.

Try to do as Suresh Suggested and if still failed then let us know.

Reply
Olister Rumao responded on 16 May 2018 6:05 AM
My Badges
Verified Answer

Hi Ashwini.123,

You need to create variable say TempDateof type Date and write the following code.

EmailUser.RESET;

CustomerLedgerEntries.RESET;

CustomerLedgerEntries.SETRANGE("Customer No.",EmailUser.No);

CustomerLedgerEntries.SETCURRENTKEY(DueDate);

CustomerLedgerEntries.ASCENDING(True);

IF CustomerLedgerEntries.FINDFIRST THEN

REPEAT

IF TempDate<>CustomerLedgerEntries.DueDate THEN BEGIN

//Send Email

TempDate =  CustomerLedgerEntries.DueDate;

END

UNTIL CustomerLedgerEntries.NEXT=0;

Reply
RockWith NAV responded on 15 May 2018 11:38 PM
My Badges
Suggested Answer

Can you please show us the code that you wrote?

Reply
Chris D'silva responded on 16 May 2018 2:39 AM
My Badges
Suggested Answer

Hi,

You can create a boolean variable say Check in customer ledger entry if mail sent then enable the boolean variable.

If (Duedate = TODAY) AND (Check =FALSE) then

Check=TRUE;

//your code

Send mail

Reply
Suresh Kulla responded on 16 May 2018 7:53 AM
Suggested Answer

Ashwini,

What you need is Loop through the customer table as main loop and inside the customer table loop check the customer ledger entries for that customer with Due Date greater then today and if you find a record then send the email, this way you will not send duplicate emails and you don't need any additional field or logic.

Reply
RockWith NAV responded on 16 May 2018 9:48 AM
My Badges
Suggested Answer

I believe you skipped one Important point. You want to send one email based on due date which is if repeating then it should send only one but for that respective customer right? If there are 4 same due date but have 2 different customers then there would be 2 email for that 2 Customers.

Try to do as Suresh Suggested and if still failed then let us know.

Reply

SBX - Two Col Forum

SBX - Migrated JS