Report printing through Job scheduler
bks
Member Posts: 115
Hi,
I am trying to print one report (using Virtual PDF) and mail it to relevant customer.
The code have written in 5961- JobScheduler-Run Object is as below:
Start date and End date are new fields in Job Scheduler Setup table which will give user defined filter.
The problem goes like this-
Cutomer- 1000 has email id as abc@xyz.com and custome - 1001 has email id as abc@pqr.com. For the given date filter- say 010108..020108, there is no record for customer- 1000. So, the code should send e-mail only to customer- 1001 (as there are some records for this customer in given date range).
Right now, my code is generating two mails- for customer 1000 and for customer 1001 and attaches the report for customer 1001 to both the e-mail which is wrong...
Please tell me where I am going wrong and how I should change my code??? ](*,)
I am trying to print one report (using Virtual PDF) and mail it to relevant customer.
The code have written in 5961- JobScheduler-Run Object is as below:
OnRun(VAR Rec : Record "Job Scheduler Setup")
CASE "Object Type" OF
"Object Type"::Report:
---- from here----
IF Cust.FINDFIRST THEN REPEAT
CustG.SETRANGE("No.",Cust."No.");
CustG.SETRANGE("Date Filter","Start Date","End Date");
CustG.SETFILTER("E-Mail",'<>%1','');
IF CustG.FINDFIRST THEN BEGIN
REPORT.RUNMODAL("Object No.",FALSE,FALSE,CustG);
Mail.NewMessage(CustG."E-Mail",'','Customer Statement','PFA the customer statement',CustG.Attachment,TRUE);
END;
UNTIL Cust.NEXT = 0;
------
Start date and End date are new fields in Job Scheduler Setup table which will give user defined filter.
The problem goes like this-
Cutomer- 1000 has email id as abc@xyz.com and custome - 1001 has email id as abc@pqr.com. For the given date filter- say 010108..020108, there is no record for customer- 1000. So, the code should send e-mail only to customer- 1001 (as there are some records for this customer in given date range).
Right now, my code is generating two mails- for customer 1000 and for customer 1001 and attaches the report for customer 1001 to both the e-mail which is wrong...
Please tell me where I am going wrong and how I should change my code??? ](*,)
0
Comments
-
You need to delete the PDF file after each customer is printed, also before calling
Mail.NewMessage
You need to check and see if there is a PDF document and if it exists you need to send the email otherwise don't send the email.
if PDF Exists then
Delete(PDF FIle)
REPORT.RUNMODAL("Object No.",FALSE,FALSE,CustG);
If PDF Exists then do
Mail.NewMessage0 -
Hi ara3n, thanks for the reply...
Can you please tell me what would be "PDF Exist" ? Is it a boolean variable? and how do I check whether it is true or false?0 -
Off topic, but you are not using the right keywords in your code.
When you need to loop through a set of records, you should not use FINDFIRST, but FINDSET. FINDFIRST is NOT a simple replacement of FIND('-').0 -
bks wrote:Hi ara3n, thanks for the reply...
Can you please tell me what would be "PDF Exist" ? Is it a boolean variable? and how do I check whether it is true or false?
well you are storing the pdf somerwhereif Exists('C\pdffile.pdf') then
Delete('C\pdffile.pdf'))
REPORT.RUNMODAL("Object No.",FALSE,FALSE,CustG);
if Exists('C\pdffile.pdf') then
Mail.NewMessage0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

