Printing
Printing labels and documents is one of the most common requirements of iDynamics Warehouse customers. As not all customers want to print the same labels and/or documents, and print formats will usually be customized for each customer, the app does not include any predefined print reports, but has been designed so that partners can easily customize which print options should be available for each document.
Printing from the Mobile App
When printing is enabled for a document and/or its lines, the app will show an extra print action in the contextual menu. Once that option is tapped, depending on what has been specified in Business Central, the app might ask for the number of copies, and/or what the user wants to print (if several options are available).
How to Enable Printing
Every time a user logs in to the app, the app connects to the server and codeunit "IDPWHS Printing Management" raises the following events, for each document that can be handled from the app: CheckPrintDocumentHeaderEnabled, CheckPrintDocumentLineEnabled.
CheckPrintDocumentHeaderEnabled
local procedure OnCheckPrintDocumentHeaderEnabled(DocumentType: Enum "IDPWHS Source Document Type"; DocumentSubtype: Enum "IDPWHS Source Document Subtype"; ActivityType: Enum "IDPWHS Activity Type"; var Options: Text; var AskForQuantity: Boolean; var Enabled: Boolean)
This event receives the following variables:
- DocumentType. The document for which the app is checking if printing is enabled.
- DocumentSubtype. For sales and purchase documents, the type of "Sales Order" or "Purchase Order". Its index equals the index of the field "Document Type" in those documents.
- ActivityType. For warehouse activity documents, the activity type (Pick, Put-Away, etc.).
- Options. A comma-separated list of possible options. If a value is assigned to this variable, this list will be shown to the user so that they can choose one of the options.
- AskForQuantity. If set to true, the app will ask for a quantity/number of copies to print.
- Enabled. False by default. Set to true in order to show the Print action to users, for this type of document.
Example
[EventSubscriber(ObjectType::Codeunit, Codeunit::"IDPWHS Printing Management", 'OnCheckPrintDocumentHeaderEnabled', '', true, true)]
local procedure OnCheckPrintDocumentHeaderEnabled(DocumentType: Enum "IDPWHS Source Document Type"; var Options: Text; var AskForQuantity: Boolean; var Enabled: Boolean)
begin
if DocumentType = DocumentType::Shipment then begin
Options := 'Labels,Shipment Document';
AskForQuantity := true;
Enabled := true;
end;
end;
The previous examples enables printing for shipment documents. When an employee taps in Print from the app, it will ask for the number of copies and to choose between "Labels" and "Shipment Document" (the first option will be selected by default).
OnCheckPrintDocumentLineEnabled
local procedure OnCheckPrintDocumentLineEnabled(DocumentType: Enum "IDPWHS Source Document Type"; DocumentSubtype: Enum "IDPWHS Source Document Subtype"; ActivityType: Enum "IDPWHS Activity Type"; var Options: Text; var AskForQuantity: Boolean; var Enabled: Boolean)
This event is identical to CheckPrintDocumentHeaderEnabled, but will enable printing at line level, instead of at document level.
What to Print
Once printing has been enabled for one or more document and/or lines, using the previous events, OnPrintDocumentHeader and OnPrintDocumentLine will be raised in Business Central when the employee requests to print from the app.
OnPrintDocumentHeader
local procedure OnPrintDocumentHeader(DocumentType: Enum "IDPWHS Source Document Type"; DocumentSubtype: Enum "IDPWHS Source Document Subtype"; ActivityType: Enum "IDPWHS Activity Type"; No: Code[20]; SelectedOption: Text; Quantity: Integer);
- DocumentType. The document type that the user wants to print.
- DocumentSubtype. For sales and purchase documents, the type of "Sales Order" or "Purchase Order". Its index equals the index of the field "Document Type" in those documents.
- ActivityType. For warehouse activity documents, the activity type (Pick, Put-Away, etc.).
- No. The document number to print.
- SelectedOption. If a list of options was specified in the CheckPrintDocumentHeaderEnabled event, this will contain the particular option that the user selected.
- Quantity. The number of copies to print/quantity entered by the user, if AskForQuantity was set to true in the CheckPrintDocumentHeaderEnabled event.
Example
[EventSubscriber(ObjectType::Codeunit, Codeunit::"IDPWHS Printing Management", 'OnPrintDocumentHeader', '', true, true)]
local procedure OnPrintShipmentHeader(DocumentType: Enum "IDPWHS Source Document Type"; No: Code[20]; Quantity: Integer; SelectedOption: Text)
var
ShipmentHeader: Record "Warehouse Shipment Header";
begin
if DocumentType <> DocumentType::Shipment then
exit;
ShipmentHeader.Get(No);
case SelectedOption of
'Shipment Document':
PrintWhseShipmentDocument(ShipmentHeader, Quantity);
'Labels':
PrintWhseShipmentLabels(ShipmentHeader, Quantity);
end;
end;
The previous example will react to the printing options enabled in the example for CheckPrintDocumentHeaderEnabled. If the user taps on the print action, and after specifying a quantity and an option, this event will be raised.
OnPrintDocumentLine
local procedure OnPrintDocumentLine(DocumentType: Enum "IDPWHS Source Document Type"; DocumentSubtype: Enum "IDPWHS Source Document Subtype"; ActivityType: Enum "IDPWHS Activity Type"; No: Code[20]; LineNo: Integer; SelectedOption: Text; Quantity: Integer)
This event is identical to OnPrintDocumentHeader, but adds an additional LineNo parameter, with the number of the line selected in the app.