Options

Set default parameters when using SAVEASPDF

fgoerlandtfgoerlandt Member Posts: 12
edited 2015-04-10 in NAV Three Tier
Hi,

We have a report with a request page with 6 boolean parameters.
So when called manually for print/preview we can set these parameters.

We also use the same report to send as e-mail. So with an e-mail button we call the report with SAVEASPDF and present the pdf in an e-mail dialog (based on the sales order confirmation e-mail of NAV 2015). In case we use the SAVEASPDF for e-mail we want 3 of the 6 boolean parameters to be checked which we would normally set on the request page.

When I do the e-mail action, the SAVEASPDF uses the parameter values as how they were set the last time when printing manually and not specifically those 3 I want by default (the SaveValues parameter on the request page is Yes)

I tried to handle this with the GUIALLOWED, but GUIALLOWED is True when using SAVEASPDF.
IF NOT GUIALLOWED THEN
  SetDefaults;

Also tried with USEREQUESTPAGE, but also here USEREQUESTPAGE is True (which is weird because when using SAVEASPDF the requestpage is not shown.
IF NOT CurrReport.USEREQUESTPAGE THEN
  SetDefaults;

I could do it by calling a function on the report before doing SAVEASPDF but then I would need to declare my report as a variable.
But I don't want that as my e-mail function is a generic one which we use for different reports so it is called as REPORT.SAVEASPDF(Number, FileName, Record);

Is there any way to check in a report how it has been called so that we now that it is run as SAVEASPDF (without request page)?
Frederik Goerlandt
Consultant
B-Con Solutions - Waregem - Belgium

Comments

  • Options
    mark_aumark_au Member Posts: 40
    I haven't used it yet, but the new "SAVEAS" function might do the job. Have a look at Codeunit 449 and see how it uses it there. Your challenges will be to:
    1. Find a way to actually save your parameters somewhere to use - the Job Queue Entry table gives an example of this
    2. Put in some extra code to convert the output stream to a file.

    It doesn't look like there's a way (at least in my 2015 Cumulative Update 1 database) to tell if the report is being run as "SAVEASPDF/SAVEASEXCEL" if the NOT GUIALLOWED call doesn't work.
  • Options
    JuhlJuhl Member Posts: 724
    You create a function in the report, that takes 6 parameters.
    You set the internal variables for the report inside this function.
    You then call this function before running the report.

    The report needs to be a variable in the calling code.
    Follow me on my blog juhl.blog
  • Options
    JuhlJuhl Member Posts: 724
    You create a function in the report, that takes 6 parameters.
    You set the internal variables for the report inside this function.
    You then call this function before running the report.

    The report needs to be a variable in the calling code.
    Follow me on my blog juhl.blog
  • Options
    MiguelCostaMiguelCosta Member Posts: 4
    Hi,
    It's an old post but...

    In which trigger did you use this:

    IF NOT CurrReport.USEREQUESTPAGE THEN
    SetDefaults;
Sign In or Register to comment.