- Print
- PDF
Tutorial
The Tutorial setup group presents two functionalities (Query-based and SSRS reports), which allow the user to learn how to call a Lasernet report, from its code. Having access to these functionalities via the interface of Dynamics 365 Finance and Operations, the user can also view the code in Visual Studio.
To this end, it is necessary to apply a model file to the environment. The model file comes in a zipped file, which can be downloaded from our Support Portal.
As a result, the user can create and further manage a Query-based report, an SSRS report, or both report types from the GUI, and then open Visual Studio to view the code.
Tutorial Model - How to Start Query-Based Lasernet Reports from X++ per Code
The Lasernet tutorial model contains code examples (source code) on how to use Lasernet FO Connector through Code - such as how to execute reports including the destinations, initialize ranges, preparation of report-dialog/dialog-fields, etc. The examples are included in both the AOT package (binary) and within the Lasernet tutorial model which contains the source code. The AOT package (binary) is for the UI and the 'Lasernet tutorial model' contains the source code.
Upon installing the Tutorial model, you can access the code for tutorial classes and forms.
Note
The tutorial classes and forms contain examples of how to execute Lasernet Connector's reports from code and how to use context code.
Classes:

Forms:

How to Call Lasernet Print Options from Code on Lasernet Query Report
The class LACTutorialStartReport contains an example of how you can call a Query report from code.

It is preferred that we use the predefined destination in the Code – but any options are available through the lacDestinationSettings – such as the following:
lacDestinationSettings.destTypes4Print(LACDestTypes4Print::UsePredefinedDest); // Indicates that the report should be executed to predefined destination.
lacDestinationSettings.defaultDestTypes4Print(LACDestTypes4DefaultPrint::None); // Indicates that if no predefined destination meets the criteria, no fallback destination should be used if fall back destination is used. Use regular methods for fallback destination specification. For example: If fall back destination is LACDestTypes4DefaultPrint::Email then fall back email is specified, lacDestinationSettings.emailTo('fallbackemail@company.com'), etc.
lacDestinationSettings.skipDestinations(NoYes::Yes); // This would mean that no report destination processing will be performed, the report will still be archived, but if used without returnFileData(true), it will not be processed in Lasernet (basically only XML file will be archived without PDF processing).
lacDestinationSettings.skipDelivery(NoYes::Yes); // Instructs report rendering process to skip file saving in storage. Normally this can be used in connection to returnFileData(true) to force synchronous file processing.
lacDestinationSettings.returnFileData(NoYes::Yes); // Indicates to process report file synchronously, and read file data into LACResultSet provided by SRSReportExecutionInfo object.
Various Permissions for Report Print Settings Dialog
lacDestinationSettings.allowCustomProperties(NoYes::Yes); // Indicates that custom properties button is shown on printer settings dialog, allowing specification of custom properties on Report printer settings dialog directly.
lacDestinationSettings.allowForcedReRun(NoYes::Yes); // indicator if the report should be fully reprocessed (true), or if it is already in Lasernet archive, no reprocessing is required) (false).
lacDestinationSettings.allowLanguageEnforce(NoYes::Yes); // Indicator to show language Id field on dialog, that can overwrite default report language.
lacDestinationSettings.allowManualArchive(NoYes::Yes); // Indicator to show "Save report to archive?" check box in printer settings dialog. If not set - automatic configuration used from report.
lacDestinationSettings.allowManualDocuRef(NoYes::Yes); // Enables modification of attachment rules for report execution, by showing controls for report attachments in printer settings dialog.
lacDestinationSettings.allowManualOverlay(NoYes::Yes); // Enables modification of overlay directly in printer settings dialog.
lacDestinationSettings.allowManualPreviewFormat(NoYes::Yes); // Enables dialog field for specification of report preview format.
lacDestinationSettings.disableUserDefined(NoYes::Yes); // Removes UsePredefinedDestionation and CustomPort from available Lasernet destination settings on dialog.
lacDestinationSettings.forceEnabled(NoYes::Yes); // Lasernet settings are normally shown only if report is found and configured for Lasernet. This property enforces that Lasernet destination settings are always shown in dialog regardless of report. (for example, reportName is not available at the time, report is not activated, or generic settings are specified).
lacDestinationSettings.onlyLaserNetDestinations(NoYes::Yes); // Indicator to show only Lasernet destination in printer settings dialog. All standard SSRS destinations will be hidden. Normally this should be used with all query-based reports.
lacDestinationSettings.manualArchive(NoYes::Yes); // Manual indicator is report should be archived. This is overwriting settings on report, and can be used with allowManualArchive(NoYes::Yes).
lacDestinationSettings.manualDocuRefType(LACManualOverwriteType::Disabled); // Manual indicator to force attachments on report to be disabled, overwritten, etc.
lacDestinationSettings.manualLanguageId('en-us'); // Manual value to overwrite report language.
lacDestinationSettings.manualOverlayType(LACManualOverwriteType::Disabled); // Manual indicator to overwrite/disable append overlay to report.
lacDestinationSettings.manualPreviewFormat('.DOC'); // Manual indicator for preview format. This value should be present in LACFileFormats table.
How to Resend an SSRS Report from Code to Lasernet Destination
Ensure the report's Resend menu item field is populated, as in the following image:

Use the following code to run the report:
class FPPrintReport
{
public static void main(Args _args)
{
WHSContainerTable containerTable;
WHSContainerId containerId = 'CONT-000000002';
// =================================== Lasernet specific printer destination settings ================================================================
SRSPrintDestinationSettings destinationSettings = newSRSPrintDestinationSettings(); // Creating print destination object
destinationSettings.printMediumType(SRSPrintMediumType::LAC); // Specifying that destination must be Lasernet (another option LACScreen)
// Configuring Lasernet specific properties
LACDestinationSettings lacDestinationSettings = destinationSettings.lacDestinationSettings();
// ==== Report Delivery settings ====
lacDestinationSettings.destTypes4Print(LACDestTypes4Print::UsePredefinedDest); // Indicates that report should be executed to predefined destination
lacDestinationSettings.defaultDestTypes4Print(LACDestTypes4DefaultPrint::None); // Indicates that if no predefined destination meets criteria, no fall back destination should be used
lacDestinationSettings.allowForcedReRun(NoYes::Yes); // indicator if report should be fully reprocessed (true), or if it is already in Lasernet archive, no reprocessing is required) (false)
select firstonly * from containerTable
where containerTable.containerId == containerId;
LACReport report =LACReport::find(ssrsReportStr(WHSContainerContents, Report));
LACResendReport::resendReportFromRecord(report.ReportName, containerTable, destinationSettings, true);
}
}
Tutorial Model - How to Start Class-Based Lasernet Reports from X++ per Code
On each FO download page, the Lasernet tutorial model is available for download. Visit the download section of our portal.

To locate the Tutorial reports in Lasernet FO Connector, navigate to Lasernet > Setup > Tutorial > Query based reports.

The button OData illustrates how to initialize and set the ranges for a class/OData report (UI). The Form LACTutorialQueryBasedReportCode contains the code (VS) - the source code is available after installing the Lasernet tutorial model.


Query Based Reports
To access the Query-based reports page, navigate to Lasernet > Setup > Tutorial > Query based reports.

If you open the Query-based reports page for the first time, click the Create report button on the top menu of the page. As a result, a Query report is added to the list of Lasernet reports.
Any setting for this report is created from code. The procedure is illustrated in the tutorial.

Once you click the Create report button, the following notification message appears:

The report you have just created is now available in the list on the Reports page (Lasernet > Common > Reports).

To proceed, add a destination type to the report:
Select the report you have created in the list on the Query-based reports page.
Define the required destination type. To this end, click Change available on the left panel of the screen.
Select the required value and click OK on the panel that appears. As a result, the value is added to the Destination type field.

Afterward, you can run the report in three different ways, and the code can be found in Visual Studio.

Report Run (Multi Select)
Select multiple records in the list on the Query-based reports page.
Click the Report run (multi select) button available on the top menu on the page to print based on your settings (destination type).

Menu Item Run
Select multiple records in the list on the Query-based reports page.
Click the Menu item run button available on the top menu on the page to open a print menu.

Generic Report Run
To run a generic report, you cannot select records in the list and include all of them at a time in the print menu.
Each of them needs to be added to the print menu manually.

SSRS Reports
To access the SSRS reports page, navigate to Lasernet > Setup > Tutorial > SSRS reports.

On this page, you can reprint an SSRS report to Lasernet. You can select multiple records belonging to the Sales Confirmation Journal at a time, and then print them using the print dialog (Resend report) or the Silent resend button.


This way, the confirmation is re-sent based on the settings you define on the right panel of the SSRS reports page.

Resend Report
To resend a report, follow these steps:
Select one or several records in the list.
Click the Resend report button available on the Action pane of the SSRS reports page.
On the right panel that appears, define the print destination settings and click OK.

Silent Resend
Clicking the Silent resend button available on the Action pane of the SSRS reports page just runs the selected reports based on the settings you define on the right panel of the screen. No print menu is available.
