Extension version 5.14


Print your own ZPL labels

Proposed solution

  • You want to print ZPL labels from the mobile device
  • You must generate the needed ZPL yourself. You can use ZPL Designer or ZebraDesigner to create the template you need.
  • You do not want to use the integrated Cloud Print Service solution

See also:

How-to: Create custom Unplanned function in Main Menu

Step 1: Create Header

Add the following code to create your new header.

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddHeaderConfigurations''', true, true)]
    procedure MyOnGetReferenceData_OnAddHeaderConfigurations(var _HeaderFields: Record "MOB HeaderField Element")
        with _HeaderFields do begin
            // Header Name

            // Input fields on the label

            // Printer list
            Set_listValues('Printer A IP;Printer B MAC');

            // Number of Labels
            Set_label('Number of labels:');


Step 2: Modify mobile config

You need let the Mobile configuration know that your new function and header is available.

Add the following to the Mobile Configuration Files to create a new page, a main menu icon as well as an action 

  • Define a new Unplanned Function -page

    <page id="MyPrintLabel" type="UnplannedItemRegistration" icon="mainmenucount-unplanned">
      <title defaultValue="My print label page"/>
      <unplannedItemRegistrationConfiguration type="MyPrintLabel" useRegistrationCollector="false">
        <header configurationKey="MyPrintLabelHeader"/>
  • Add Icon to main menu for the unplanned function

    <menuItem id="MyPrintLabel" displayName="MyPrintLabel" icon="mainmenuprint" alwaysEnabled="true"/>
  • Add action to context menu. We use Receive.

        <open id="MyPrintLabel" title="Print my labels" icon="mainmenuprint"> </open>

Step 3: Handle posting / Generate ZPL

When the Header has been accepted a final request is made to "Post" the information ("PostAdhocRegistration").

In this step you must read the collected values and create the ZPL.

   [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml''', true, true)]
    procedure OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml(var _XMLRequestDoc: XmlDocumentvar _XMLResponseDoc: XmlDocument; _RegistrationType: Textvar _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
        Item: Record Item;
        TempHeaderFilter: Record "MOB NS Request Element" temporary;
        MOBToolbox: Codeunit "MOB Toolbox";
        MobWmsLanguage: Codeunit "MOB WMS Language";
        MobRequestMgt: Codeunit "MOB NS Request Management";
        XMLResponseData: XmlNode;
        Status: Text;
        PrintCommand: Text;
        LotNo: Text;
        ItemNumber: Text;
        Printer: Text;
        PrinterAddress: Text[50];
        ExpirationDate: Date;
        Quantity: Decimal;
        NoOfLabels: Decimal;
        if _RegistrationType = 'MyPrintLabel' then begin

            MobRequestMgt.SaveAdhocFilters(_XMLRequestDoc, TempHeaderFilter);

            // Read the request field values 
            ItemNumber := TempHeaderFilter.GetValue('ItemNumber');
            LotNo := TempHeaderFilter.GetValue('LotNo');
            Printer := TempHeaderFilter.GetValue('Printer');
            Quantity := TempHeaderFilter.GetValueAsDecimal('Quantity');
            NoOfLabels := TempHeaderFilter.GetValueAsDecimal('NoOfLabels');
            ExpirationDate := TempHeaderFilter.GetValueAsDate('ExpirationDate');


            // Generate your ZPL
            PrintCommand += '^XA';
            PrintCommand += '^FO50,50^ADN,54,30^FD' + Item.Description + '^FS';
            PrintCommand += '^FO50,130^BCN,100,Y,N,N^FD' + ItemNumber + '^FS';
            PrintCommand += '^FO50,280^ADN,54,30^FDQty: ' + FORMAT(Quantity, 09'^FS';
            PrintCommand += '^FO50,380^ADN,54,30^FDExp: ' + FORMAT(ExpirationDate, 09'^FS';
            PrintCommand += '^FO50,500^ADN,54,30^FDLOT: ^FS';
            PrintCommand += '^FO200,470^BCN,100,Y,N,N^FD' + LotNo + '^FS';
            PrintCommand += '^PQ' + FORMAT(NoOfLabels',0,0,';
            PrintCommand += '^XZ';

            // Convert printer name to a network address 
            case Printer of
                'Printer A IP':
                    PrinterAddress := '1921681010';
                'Printer B MAC':
                    PrinterAddress := '00225832FDAB';

            // Create print response to mobile device
            MOBToolbox.InitializeResponseDocWithDesc(_XMLResponseDoc, XMLResponseData, MobWmsLanguage.GetMessage('PRINT_RESPONSE'));
            MOBToolbox.AddZPLPrintCommandToRequest(XMLResponseData, PrinterAddress, PrintCommand);

            Status := 'OK';
            _IsHandled := true;


Step 4: Respond with ZPL

The mobile device will issue the print.

The XML response should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<response xmlns="" messageid="89CF29D1-941A-4459-8767-B83203C67355" status="Completed">
  <description>Print OK</description>
  <responseData xmlns="">
    <print xmlns="">
      <printCommand>^XA^FO50,50^ADN,54,30^FDIntense Orange^FS^FO50,130^BCN,100,Y,N,N^FDtf-002^FS^FO50,280^ADN,54,30^FDQty: 1^FS^FO50,380^ADN,54,30^FDExp: 2020-03-24^FS^FO50,500^ADN,54,30^FDLOT: ^FS^FO200,470^BCN,100,Y,N,N^FD^FS^PQ0,0,0,^XZ</printCommand>

The main menu icon

The header fields