Introduction: In this blog, I will be giving the procedure to save the selected Posted Sales Invoice as a PDF document in a particular mentioned path.


Microsoft Dynamics NAV


  1. Create the following C/AL global variables in Page 143 Posted Sales Invoices.
Name DataType Subtype Length
FileName Text   200
FileMgt Codeunit File Management  
SalesInvoiceHeader Record Sales Invoice Header  
FolderName Text    
PDFFileName Text    


  1. I have created a new action on Page 143 Posted Sales Invoices to save the selected Posted sales invoice as a PDF document. You can select multiple records and save all of them at once in a specific path. To select many records at once and perform some action on all, you can refer my blog using the below link:

  1. To save the Posted Sales Invoice as a PDF document add the following code:
FileName := FileMgt.ServerTempFileName('PDF');
  1. Now to get reference of the Posted Sales Invoice record for which the report needs to be saved, you need to write the following code snippet:
SalesInvoiceHeader.SETRANGE("No.", Rec."No.");

I have entered the required report ID in a newly created custom setup table. From that table, I am fetching the Report ID. The standard sales invoice report ID is 206. If you have a customized report you need to enter the respective customized report ID.

  1. To download and save this particular Posted sales Invoice report, the following needs to be written:

Save the folder path in a variable FolderPath. You can enter the Folder path in a newly created custom table and fetch it from there.


You can create customized folders using C/AL code according to the posting date of the Posted Sales Invoice as mentioned in my previous blog using the link below and save the customized folder name in a FolderName variable.

Procedure to create custom folders in a specific location using C/AL code in Dynamics NAV

This will save the required Posted Sales Invoice record report in the mentioned location.

Thank you!