Job queue issue

madsmorremadsmorre 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);

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    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?
  • madsmorremadsmorre Member Posts: 40
    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 either
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    EmailMgt is it standard or customized?
    how di you remove requestpage?
    I mean to say handle the OK button of request page
  • madsmorremadsmorre Member Posts: 40
    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...
Sign In or Register to comment.