Hi,
I have been trying to construct a codeunit to save a report as a pdf which works for thing’s like invoices and quotes where I just need to pass a simple filter with the document number however now I am trying to use the same code for generating a statement which requires 2 parameters and I can’t seem to get it to work correctly.
The codeunit executes correctly and using procmon I can see the access attempt on the directory and the file being written but NAV then deletes the pdf files which I presume is because it contains no data. If I run the report manually with the same filters however it generates without any problems.
I presume I have probably gone wrong with my filters in the codeunit which is why it is not finding data so I would appreciate it if anyone could shed some light on it.
FileName:=‘C:\statements\statement.pdf’;
Customer.SETFILTER(“No.”,‘01147514’);
Customer.SETRANGE(“Date Filter”,01012007D,10042013D);
repStatement.SETTABLEVIEW(Customer);
repStatement.SAVEASPDF(FileName);
The above code I originally found on a blog for generating invoices however I can’t remember the link to provide it as a reference. The repStatement is set as a variable to our RTC statement report.