Job queue issue
madsmorre
Member Posts: 40
Hi
I'm running two reports in a job queue (NAV 2016)
The first report post all sales orders that have been delivered the same day. This works fine - everything is posted.
Then I have a simple report that sends the invoices to the customer on email (as PDF). This report works fine, when I run the report manually (just pressing OK on the report), but when it is run in the Job queue nothing happens - exept that it is registred as run successfully in the job queue log entry.
Does anyone have any suggestions on why this happens...
Code to send report as PDF
//>>OnRun
CLEAR(SalesInvoiceHeader);
SalesInvoiceHeader.SETFILTER("No.",'141721'); //Only one invoice - for testing
IF SalesInvoiceHeader.FINDSET THEN REPEAT
RecRef.GETTABLE(SalesInvoiceHeader);
ReportID := EmailMgt.GetReportIDFromRecRef(RecRef);
IF ReportID = 0 THEN
ERROR('No report');
EmailMgt.SendReport(ReportID,RecRef,SalesInvoiceHeader."Bill-to E-mail",TRUE);
MailCount += 1;
UNTIL SalesInvoiceHeader.NEXT = 0;
//EmailMgt.SendReport
ErrorMessage := '';
IF ReportID = 0 THEN
ErrorMessage := Text012;
IF ErrorMessage = '' THEN
ErrorMessage := SetupEmailTemplate(RecRef,RecipientEmail,Silent,EmailTemplateHeader);
IF EmailTemplateHeader."Default Recipient Address" = '' THEN
EXIT;
IF ErrorMessage = '' THEN
ErrorMessage := CreateSmtpMessageFromEmailTemplate(EmailTemplateHeader,RecRef,ReportID);
AddEmailAttachmentsToSmtpMessage(EmailTemplateHeader);
IF ErrorMessage = '' THEN BEGIN
Filepath := GetFilepath();
Filename := GetFilename(EmailTemplateHeader,RecRef);
RecRef.SETRECFILTER;
IF NOT PrintPDF(ReportID,RecRef,Filepath,Filename) THEN
ErrorMessage := STRSUBSTNO(Text006,ReportID);
END;
IF ErrorMessage = '' THEN BEGIN
IF NOT AddFileToSmtpMessage(Filepath + Filename) THEN
ErrorMessage := Text009;
IF ERASE(Filepath + Filename) THEN;
END;
IF ErrorMessage = '' THEN
ErrorMessage := AddAdditionalReportsToSmtpMessage(EmailTemplateHeader,RecRef,Filepath);
IF ErrorMessage = '' THEN
ErrorMessage := SendSmtpMessage(RecRef,Silent);
FileManagement.DeleteServerFile (Filepath + Filename);
IF (ErrorMessage <> '') AND NOT Silent THEN
ERROR(ErrorMessage);
EXIT(ErrorMessage);
I'm running two reports in a job queue (NAV 2016)
The first report post all sales orders that have been delivered the same day. This works fine - everything is posted.
Then I have a simple report that sends the invoices to the customer on email (as PDF). This report works fine, when I run the report manually (just pressing OK on the report), but when it is run in the Job queue nothing happens - exept that it is registred as run successfully in the job queue log entry.
Does anyone have any suggestions on why this happens...
Code to send report as PDF
//>>OnRun
CLEAR(SalesInvoiceHeader);
SalesInvoiceHeader.SETFILTER("No.",'141721'); //Only one invoice - for testing
IF SalesInvoiceHeader.FINDSET THEN REPEAT
RecRef.GETTABLE(SalesInvoiceHeader);
ReportID := EmailMgt.GetReportIDFromRecRef(RecRef);
IF ReportID = 0 THEN
ERROR('No report');
EmailMgt.SendReport(ReportID,RecRef,SalesInvoiceHeader."Bill-to E-mail",TRUE);
MailCount += 1;
UNTIL SalesInvoiceHeader.NEXT = 0;
//EmailMgt.SendReport
ErrorMessage := '';
IF ReportID = 0 THEN
ErrorMessage := Text012;
IF ErrorMessage = '' THEN
ErrorMessage := SetupEmailTemplate(RecRef,RecipientEmail,Silent,EmailTemplateHeader);
IF EmailTemplateHeader."Default Recipient Address" = '' THEN
EXIT;
IF ErrorMessage = '' THEN
ErrorMessage := CreateSmtpMessageFromEmailTemplate(EmailTemplateHeader,RecRef,ReportID);
AddEmailAttachmentsToSmtpMessage(EmailTemplateHeader);
IF ErrorMessage = '' THEN BEGIN
Filepath := GetFilepath();
Filename := GetFilename(EmailTemplateHeader,RecRef);
RecRef.SETRECFILTER;
IF NOT PrintPDF(ReportID,RecRef,Filepath,Filename) THEN
ErrorMessage := STRSUBSTNO(Text006,ReportID);
END;
IF ErrorMessage = '' THEN BEGIN
IF NOT AddFileToSmtpMessage(Filepath + Filename) THEN
ErrorMessage := Text009;
IF ERASE(Filepath + Filename) THEN;
END;
IF ErrorMessage = '' THEN
ErrorMessage := AddAdditionalReportsToSmtpMessage(EmailTemplateHeader,RecRef,Filepath);
IF ErrorMessage = '' THEN
ErrorMessage := SendSmtpMessage(RecRef,Silent);
FileManagement.DeleteServerFile (Filepath + Filename);
IF (ErrorMessage <> '') AND NOT Silent THEN
ERROR(ErrorMessage);
EXIT(ErrorMessage);
0
Comments
-
you have to remove that just pressing ok request page while running from Job Queue
what is variable EmailMgt?
check SendReport parameters.
may be last one is related to it?0 -
Hi Mohana
I removed the Request page, but that didn't do it.
The EmailMgt is a codeunit the handles the SMTPsending of an email.
I also tried to copy the code to a codeunit instead of a report, but it doesn't help either0 -
EmailMgt is it standard or customized?
how di you remove requestpage?
I mean to say handle the OK button of request page0 -
EmailMgt is a customized function. It work though everytime I run the function manually.
I have skipped the report and run the functions in a codeunit. Again - it works when i press the button, but not when I run it through Job Queue.
Could it be something with the handling of the pdf-file to be attached?
It works from the client - but not from server...0
Categories
- All Categories
- 75 General
- 75 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
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
