RTC CurrReport.PREVIEW and ReportViewer Toolbar

ceccomilceccomil Member Posts: 25
edited 2011-10-14 in NAV Three Tier
Hi everybody,
Is it possible to show export command button in the reportviewer toolbar if in the report C/AL code was called the IF CurrReport.PREVIEW... statement??
Thanks in advance
Cecco

Comments

  • BeliasBelias Member Posts: 2,998
    ceccomil wrote:
    Hi everybody,
    Is it possible to show export command button in the reportviewer toolbar if in the report C/AL code was called the IF CurrReport.PREVIEW... statement??
    Thanks in advance
    Cecco
    I think so...why not?did you noticed that you can't show it?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ceccomilceccomil Member Posts: 25
    Belias wrote:
    did you noticed that you can't show it?

    Yes Sir! Try to watch the preview of invoice (report 206) if the 2 If CurrReport.Preview Statement are enabled print and export commands are invisible in the report preview toolbar.
    Take a look to the code below.. if you comment those, you'll get both print and export commands
    In the Sales Header OnAfterGetRecord
    IF LogInteraction THEN
      IF NOT CurrReport.PREVIEW THEN BEGIN
        IF "Bill-to Contact No." <> '' THEN
          SegManagement.LogDocument(
            4,"No.",0,0,DATABASE::Contact,"Bill-to Contact No.","Salesperson Code",
            "Campaign No.","Posting Description",'')
        ELSE
          SegManagement.LogDocument(
            4,"No.",0,0,DATABASE::Customer,"Bill-to Customer No.","Salesperson Code",
            "Campaign No.","Posting Description",'');
      END;
    

    and in CopyLoop OnPostDataItem
    IF NOT CurrReport.PREVIEW THEN
      SalesInvCountPrinted.RUN("Sales Invoice Header");
    
  • BeliasBelias Member Posts: 2,998
    :shock:
    I'm wondering why they does not come up...maybe because you don't want to have the possibility to save the doc unless all the instructions are executed (if there wasn't this "feature" in this report you could have run a preview, and then saved the report without increasing the no. of copies and saving the log).
    This is not so bad in my opinion...you can use saveasexcel and saveaspdf, afterall
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ceccomilceccomil Member Posts: 25
    Belias wrote:
    This is not so bad in my opinion...you can use saveasexcel and saveaspdf, afterall

    Well.. after a while I tried CurrReport.SAVEASPDF... on the OnPostReport action.. but the only thing I got it's my file with 0 byte.. And obiouvsly an error message: "I/O exeption".

    That it's only the first step, because instead of saving the file on the client it will save the file on the server where ServiceTier is running... [-(

    Any suggests?
  • BeliasBelias Member Posts: 2,998
    :-k you failed to use the function correctly...check the online help (of nav2009 of course) in order to see how tu save a report as pdf
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ceccomilceccomil Member Posts: 25
    I checked up the online help, but it not says to much... and no samples are available.

    Do you got some examples? on using SAVEASPDF or SAVEASEXCEL function with report 206

    here is my code onPostReport()
    PdfCreated := REPORT.SAVEASPDF(206,'C:\TEMPNAVFILES\def.pdf', "Sales Invoice Header");
    IF (PdfCreated = TRUE) THEN
    MESSAGE('FILE HAS BEEN CREATED')
    ELSE
    MESSAGE('FILE NOT CREATED);
    

    No message appear.. just I/O exception.
  • BeliasBelias Member Posts: 2,998
    is the report actually printing something?
    are you running this code from an action?(that calls a codeunit or something, you know) - this is the correct option -
    did you try to search mibuso for saveaspdf?i have never used saveaspdf function up to now, i'm only telling you all i know about it. :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ceccomilceccomil Member Posts: 25
    I'm done! =D>

    I'll post my solution for helping others (Assuming they need help... :-k )


    In Page 143 I've added a promoted Action in the Process container and I called it "SaveASPDF" (Action21)
    <Action21> - OnAction()
    CurrPage.SETSELECTIONFILTER(SalesInvHeader);
    REPORT.SAVEASPDF(206, 'C:\temp\default.pdf', SalesInvHeader);
    Tofile := 'default.pdf';
    PdfDownloaded := DOWNLOAD('C:\temp\default.pdf', 'Save PDF As..', 'C:\','PDF file(*.pdf)|*.pdf', Tofile );
    

    Now it's perfectly working also with multiple invoices selection! :lol:
  • BeliasBelias Member Posts: 2,998
    Of course, dowload function! #-o
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • AleksKAleksK Member Posts: 1
    There is a very good reason why Microsoft does not allow you to print (or save as PDF, Excel etc) a report from preview mode whenever it detects CurrReport.PREVIEW being executed in Navision code of the report.
    So instead of circumventing standard well-thought Navision functionality you should really try to understand why PREVIEW function was used in the report and once you understand what was the reason to prevent the user to print the report you should talk to your user about it and ask him if that reason is valid in his case. And only if the reason is not valid for that particular user you can modify the report by commenting out CurrReport.PREVIEW lines of code together with all the related code.

    An example is when the user uses number series to generate unique numbers for Invoices but before actually printing the Invoice he wants to preview it. Your task is to ensure that the report is not printed (or exported as PDF and printed from PDF etc) from preview mode because otherwise user could create multiple Invoices for different Customers with the same Invoice No.
  • deV.chdeV.ch Member Posts: 543
    The problem is that the previous function is useless for retrieving a feedback where the pages are braken, for. eg. if you want to save paper and don't have a single line on a 2. page you could try to remove a line of text ore something like that, but you don't have that option you need to print a document to know how it exactly looks on paper. In classic client you have a real preview where the report is rendered the same way it gets printed.

    Not beeing able to print & export is no problem, but not showing the layout correctly like it will be printed is a very very bad user experience!
Sign In or Register to comment.