mibuso.com

Microsoft Business Solutions online community
It is currently Fri May 24, 2013 11:11 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 6:54 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
Hi,

I have create the codeunit to use Bullzip PDF to generate PDF. The function working great, but when I put it in the Job Queue then there is an error message,"You cannot use C/AL variables of type DIALOG when running the Application Server for Microsoft Dynamics NAV Classic."

I have disable any dialog in the report.

In the codeunit, I believed I disable popup window for Bullzip.
Code: Select all
BullZipPDF.Init;
BullZipPDF.LoadSettings;
BullZipPDF.SetValue('OutPut', PDFFilePath + PDFFileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowSaveAS', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);

REPORT.RUNMODAL(50007, FALSE, FALSE);

Did I miss anything??
Thanks


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 8:21 pm 
Online
Site Admin
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Sun Nov 07, 1999 8:01 am
Posts: 3294
Location: Wilrijk
Country: Belgium (be)
This code-extract looks fine to me, but as you didn't publish all code, we can only guess why it gives you that error.

_________________
No support using PM or e-mail - Please use this forum.
Search is your friend || Mark your Topic as SOLVED (= green checkmark) when your question is answered || Read the Forum Rules before making a posting

»»» Mark your calendar: NAV TechDays 2013 - 7 & 8 November 2013 ««« Visit the conference website: www.navtechdays.com


Top
 Profile  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 8:32 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
sorry about that.. This is my codeunit
Code: Select all
IF ISCLEAR(BullZipPDF) THEN
  CREATE(BullZipPDF);

PDFFilePath := 'E:\Flash\';
PDFFileName := 'FlashReport_'+FORMAT(DATE2DMY(TODAY,2))+'_'
               +FORMAT(DATE2DMY(TODAY,1))+'_'+FORMAT(DATE2DMY(TODAY,3)) + '.pdf';

BullZipPDF.Init;
BullZipPDF.LoadSettings;
BullZipPDF.SetValue('OutPut', PDFFilePath + PDFFileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowSaveAS', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);

REPORT.RUNMODAL(50007, FALSE, FALSE);

IsDone := FALSE;
I := 0;
REPEAT
  IF FILE.EXISTS(PDFFilePath+PDFFileName) THEN BEGIN
    IF testFile.OPEN(PDFFilePath+PDFFileName) THEN BEGIN
      IsDone := TRUE;
    END;
  END;
  I += 1;
  SLEEP(1000);
UNTIL (I > 60) OR IsDone;

IF IsDone THEN BEGIN
  SenderName := 'Navision';
  SenderAddress := 'support@something.com';
  SendTO := 'someone@something.com';
  Subject := 'Report.';
  Email.CreateMessage(SenderName, SenderAddress, SendTO, Subject,
    'This is an automatic generated email from Navision.  Please do not reply.', FALSE);
  Email.AddAttachment(PDFFilePath+PDFFileName);
  Email.Send;
END;


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 8:55 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Fri Jun 11, 2004 9:05 pm
Posts: 4858
Location: Los Angeles, CA
Country: United States (us)
My guess is that the report is bringing up the "Searching for record..." dialog box because the wrong key is used.

_________________
Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work


Top
 Profile E-mail WWW  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 9:01 pm 
Offline

Joined: Sat Feb 18, 2012 2:42 am
Posts: 53
Location: Portland, OR
Country: United States (us)
Hi, is your variable TestFile set to DataType of Dialog? If so, that's probably where you are getting tripped up


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 9:19 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
jspopp wrote:
Hi, is your variable TestFile set to DataType of Dialog? If so, that's probably where you are getting tripped up

my testFile is File Datatype


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 9:19 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
Code: Select all
Name   DataType   Subtype   Length
PDFFilePath   Text      250
PDFFileName   Text      250
DefaultPrinter   Text      100
TempDir   Text      100
FlashReport   Report   Flash Report   
IsDone   Boolean      
I   Integer      
testFile   File      
SendTO   Text      1000
Email   Codeunit   SMTP Mail   
SenderName   Text      100
SenderAddress   Text      1024
Subject   Code      50
BullZipPDF   Automation   'Bullzip'.PDFPrinterSettings   


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 9:26 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
When I run the Codeunit via Object designer this window pop up
Image


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 9:36 pm 
Offline

Joined: Sat Feb 18, 2012 2:42 am
Posts: 53
Location: Portland, OR
Country: United States (us)
Try commenting these lines out (or removing it from your code) and then run the NAS. See if that fixes the issue


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 9:57 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
jspopp wrote:
Try commenting these lines out (or removing it from your code) and then run the NAS. See if that fixes the issue


I comment out

BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowSaveAS', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);

still no luck...

I think it's the print progress windows (the screenshot above), but i don't know how to disable that. The ShowProgress and showProgressFinished are already set to no.


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 10:40 pm 
Offline

Joined: Sat Feb 18, 2012 2:42 am
Posts: 53
Location: Portland, OR
Country: United States (us)
Try commenting this line out:

IF testFile.OPEN(PDFFilePath+PDFFileName) THEN BEGIN


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Tue Apr 17, 2012 10:49 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
If I comment everything out, still have the same error.... ](*,)
Wait after I compile the Codeunit, do I have to restart NAS??


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Wed Apr 18, 2012 1:02 am 
Offline

Joined: Sat Feb 18, 2012 2:42 am
Posts: 53
Location: Portland, OR
Country: United States (us)
Yes, restart the NAS and then see what happens after that


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Wed Apr 18, 2012 3:41 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
After restart the NAS during down time, I don't have the error anymore :thumbsup: .
But even in the job Queue Log Entries shows Success, there is not time stamp in the End Date/Time and no PDF was generated and no email send... ](*,) The status of record in Job Queue Entries stays in In Process... AND I can't stop the NAS


Top
 Profile E-mail  
 
 Post subject: Re: Use NAS to generate PDF Then attach to an Email
PostPosted: Wed Apr 18, 2012 5:19 pm 
Offline

Joined: Thu Feb 17, 2011 8:00 pm
Posts: 34
Country: United States (us)
So the problem solved, it's very simple and stupid... :oops:
I login the server as the user account use by the NAS service then set the BullzipPDF printer as the default printer. Problem solved...


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: lzr and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: