0

Launching Jet from NAV RTC

I have seen this article that discusses how to launch a Jet report from the NAV Classic Client - https://jetsupport.jetreports.com/hc/en-us/articles/219403007

I remember (and finally found) a few years ago when Hans Fousert posted that he had worked out a way to do this from the RTC. Unfortunately, the blog post he linked to no longer exists.

I did some searching, found a few things, and was able to put together this method (which appears to work - at least from the 2009 RTC).

I understand that this is not officially supported, but I thought it might help someone.

Here's the end result:



Actions

R2 has a new way to maintain Page Actions. In the Page Designer you select View, Page Actions to get to the Action Designer.

Add new actions (and maybe even an action group) for each Jet Reports option. I added 3: 1 for E-mail, 1 for Excel and 1 for PDF in the page from the screen shot above.


C/AL Code

The code for the action named 'Excel' is not very different from the code in the Classic version. The only thing is an extra 'true' in the CREATE command which means it will be executed on the client instead of the middle tier.


This is what the code looks like (pretty much taken directly from the knowledgebase article above) now in the OnAction-trigger:

IF CREATE (XL, TRUE, TRUE) THEN BEGIN
XL.Workbooks.Open('C:\Program Files (x86)\JetReports\JetReports.xlam');

Workbook := XL.Workbooks.Open ('C:\path_to_report\name_of_report.xlsx');
Workbook.Names.Item ('Customerno').RefersToRange.Value := "No.";
XL.Run ('JetMenu', 'Report');

XL.Interactive := TRUE;
XL.Visible := TRUE;
Worksheet := Workbook.Worksheets.Item ("No.");
CLEAR (XL);
END;



Launching Autopilot

This was a bit more difficult to find and figure out. The SHELL command cannot be used on the RTC. Instead you have to use an automation control. Besides that, there are some minor differences in the text globals.

Once these globals are defined you need to add some code to the OnAction-trigger:

CREATE (WshShell, FALSE, ISSERVICETIER);
WshShell.Exec (JetAutopilot + ' ' + STRSUBSTNO (JetParamPDF, "No.", "No."));
CLEAR (WshShell);

I'm no expert in this, but (like I said) maybe someone will find it useful.

    1 comment

    Please sign in to leave a comment.