How to show the current record in print report automatically..??

Hi all,

Thank you all in advance for the kind of help you all are…:slight_smile:

I have created a report in export invoice level. I need to print the current record when I preview the report. When I manually enter the data in the filter options like ‘document type’ or ‘No’, I am able to view that that in print report. However, I want the current order details to populate automatically in the report filter options which then I can print preview.

I know I can not ask for urgent help, and I respect what you say…:-), However, quick reply would be really appreciated and I would be very thank full like always…



Hi Fahim,

A good developer is also good at using “copy-paste”! So take a look in standard NAV who this is done. There are tons of examples.

There are several ways to do this.The key is not just to set the report into your action menus with the simple “RunObject” as this doesn’t allow you to pass any parameters. Instead you must write a few lines of code.

Either creating an “SetPrintRecord” initiate function in the report and call it from your page/form.

Or the most simple way, where you simply call the report with the variable, but this of course requires that the primary record on the report is the one you’re calling the report with.


Thank you for quick reply, I do agree to you :slight_smile: however, I am not able to find the code for it. I am new and do not know what could be the code for it. Like I did everything in the past to post to excel but didn’t know to press F9 after all the data item and write the code to create excel sheet in onpost section. Hope you understand. If you can just guide a bit I will try to get it done.

Thanks a lot in advance…:slight_smile:

I have added the filter fields but unable to populate the current data to it :frowning:

Open page Purchase Order (50)

Go to Actions

Select print

Press F9

and read/follow the code

Hi Fahim,

Which method to use really depends on how your report is structured. If the primary table used in the report isn’t the same table as the one on the page you’re calling it from then it doesn’t work. But if it is then it’s quite easy: REPORT.RUN(YourReportNo, TRUE, FALSE, YourRecord);

Eventually check codeunit 229 (Document-Print).

Hi Fahim,

Did you try the property “Save Values” in the Request form ( Where you are showing the Report filters ) just try with “Yes” value.

Dear all,

Thank you for your kind support. I will try to do it and let you know .:slight_smile:

Hope something will work out.




I have not kept anything on request form…!!! do I need to add filter here as well?

I have only added in the report.


ya you just try by adding on reuest form and by using the “Save Values” property set to Yes.


I just went to request form and in property(Shift F4) changed “Save Values” to yes. It still does not work.


I don’t know which version of NAV you are using ?

Following what I understand from your query is that user will go to the document and click on button to display the report .

You can try following code for display

Define ltSaleInvHdr as Sales Invoice Header

Define lrProformaInvoice as Report








Hi all,

I tried but could not get “Eventually check codeunit 229 (Document-Print).” I am not able to created variable as report. Does this comes same as as we select data item in global variables. I am using nav 2009 R2



Sorry for tdhe delay, got stuck with other work. Yes, amol you got it correct. I want to show the record on the current form to print and for that I want to have “Document Type” and “No.” these two fields to auto populate in the filter as per the current record user is viewing. Your code though seem promising however, I am not able to implement it properly.

I am not able to create to "Define lrProformaInvoice as Report " I am using “Sales Header” and “Sales Line” date items. Also, where do I write the above code please. and how do I go about it.




Do you want to print report for the record which currently in Form or Page ? for example a user working in sales order no 2001 and he prints that sales order then, in ReqFilterFields should automatically show 2001 ? please refer the screen shot




Yes, Marshal absolutely…!! I am working on the enclosed form it is Final Export Invoice form…

I guess it is not visible here. However, I hope I am able to make you understand what I am looking for. :slight_smile:


Please try this write this onPush() of the button,

Create a Recorevariable of the dataitem of report and report variable of the report which you want to run

SalesHeader.SETRANGE(SalesHeader.“Document Type”,SalesHeader.“Document Type”::Order);

Hi Marshal,

I have create record variable of “Sales Header” as SalesHeader do I need to create Orderconfirmation as report of “Report name I am using”? Also, do I need to do this in report or the form from where I will click preview??

I guess I am just about to get it sorted with your little more help. Thanks a ton for helping.

Awaiting reply :slight_smile:



Let’s solve that using basic application solution:

  1. I assume that the form/page you are want to print is Posted Sales Invoice.
  2. Go to Administration | Application Setup | Sales & Marketing | Report Selection (Sales)
  3. Choose: Invoice
  4. Change the Standard Default Report ID there, into your New Custom Report ID
  5. Try to print from the standard button in Posted Sales Invoice form, your report will be run

If you want to know, how could your report be called, and directly to the current record, now try to debug it when you push the Print button.

Hope it helps.