Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
titleRequirement

This article requires Mobile WMS Extension version MOB5.23

Case

Excerpt

Print Label on Planned Posting, i.e. Receive, Pick, Put-away, Ship, Move etc.

Proposed solution

This examples prints on posting of Warehouse Receipt Lines

  • You want to print labels from the mobile device
  • You want to use the integrated Cloud Print Service solution
  • The label should be printed automatically when posting occurs  

Step 1: Add printer steps on posting

In order to determine when, where and what to print, we add a step on posting

Add the following code to create a step on posting.

See also: How-to: Add Header Step

  // In order to determine when, where and what to print, we add a step on posting
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyHeader''', true, true)]
    local procedure MyOnGetReceiveOrderLines_OnAddStepsToAnyHeader(_RecRef: RecordRefvar _StepsElement: Record "MOB Steps Element")
    var
        MobPrint: Codeunit "MOB Print";
    begin
        if (_RecRef.Number() in [DataBase::"Warehouse Receipt Header", Database::"Purchase Header"]then begin
            _StepsElement.Create_ListStep(1'Printer');
            _StepsElement.Set_header('Label print');
            _StepsElement.Set_listValues(' ;' + MobPrint.GetMobilePrinters('Item Label 3x2', ''))// Allow user to select blank printer + the printers attached to this labeltemplate
            _StepsElement.Set_helpLabel('If you want a label, please select a printer.');
        end;

    end;

Select the right event

The example code is for receive.

Select another event if you are working with another function.

Filter by label (Content by label)
showLabelsfalse
max150
showSpacefalse
sorttitle
excludeCurrenttrue
cqllabel = "integrationevent" and label = "onaddstepsto" and label in ("order","orders")

Step 2:  Handle steps on posting to issue print

    // We read the collected step (printer).
    // Issue a print based on printer, label and the current context (Order Line)
    // Print engine will build a dataset   [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnPostReceiveOrder_OnAfterPostAnyOrder''', true, true)]
    local procedure MyOnPostReceiveOrder_OnAfterPostAnyOrder(var _OrderValues: Record "MOB Common Element"; _RecRef: RecordRefvar _ResultMessage: Text)
    var
        MobPrinter: Record "MOB Printer";
        TempPrintParameter: Record "MOB Print REST Parameter" temporary;
        MobPrint: Codeunit "MOB Print";
        MobLanguage: Codeunit "MOB WMS Language";
        MobPrintBuffer: Codeunit "MOB Print Buffer";
        PrintCommand: Text;
    begin
        // -- Prepare to Print
        // Did user select a printer?
        if _OrderValues.GetValue('Printer'' ' then
            exit;
        // -- Print
        // Init printer parameters
        Evaluate(TempPrintParameter.Printer, _OrderValues.GetValue('Printer'));
        TempPrintParameter."Label-Template Name" := 'Item Label 3x2';
        // Set parameters
        MobPrint.SetSourceRecRef(_RecRef);
        MobPrint.SetRequestElementsFromOrderValues(_OrderValues);
        // Perform cloud print
        if MobPrint.Run(TempPrintParameterthen begin
            // Command is returned from cloud
            TempPrintParameter.GetResponseContentAsBase64Text(PrintCommand);
            // Convert the printer selected to an Address
            MobPrint.GetPrinterFromName(MobPrinter, TempPrintParameter.Printer);
            // Save response to be sent in the next Mobile response
            MobPrintBuffer.Add(MobPrinter.Address, PrintCommand);
        end else
            // If failed, append Error to ResultMessage 
            _ResultMessage := _ResultMessage + ' ' + MobLanguage.GetMessage('PRINT_FAILED'': ' + GetLastErrorText();
    end;

Select the right event

The example code is for receive.

Select another event if you are working with another function.

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
cqllabel = "onafterpost" and label = "integrationevent"

Step 3: Modify print "Dataset" (optional)

Use this event to modify the automatically generated dataset, to suit your label needs.

Info
titleRequirement

This article requires Mobile WMS Extension version MOB5.23

Case

Excerpt

Print Label on Planned Posting, i.e. Receive, Pick, Put-away, Ship, Move etc.

Proposed solution

This examples prints on posting of Warehouse Receipt Lines

  • You want to print labels from the mobile device
  • You want to use the integrated Cloud Print Service solution
  • The label should be printed automatically when posting occurs  

Step 1: Add printer steps on posting

In order to determine when, where and what to print, we add a step on posting

Add the following code to create a step on posting.

See also: How-to: Add Header Step

  // In order to determine when, where and what to print, we add a step on posting
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyHeader''', true, true)]
    local procedure MyOnGetReceiveOrderLines_OnAddStepsToAnyHeader(_RecRef: RecordRefvar _StepsElement: Record "MOB Steps Element")
    var
        MobPrint: Codeunit "MOB Print";
    begin
        if (_RecRef.Number() in [DataBase::"Warehouse Receipt Header", Database::"Purchase Header"]then begin
            

Case

Excerpt

Print Label on Planned Posting, i.e. Receive, Pick, Put-away, Ship, Move etc.

Proposed solution

This examples prints on posting of Warehouse Receipt Lines

  • You want to print labels from the mobile device
  • You want to use the integrated Cloud Print Service solution
  • The label should be printed automatically when posting occurs  


Example 1: Print on Posting Warehouse Pick

    // Step 1: Add Header steps
    // In order to determine when, where and what to print, we add a step on posting
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Pick", 'OnPostPickOrder_OnAddStepsToAnyHeader', '', true, true)]
    localprocedure OnPostPickOrder_OnAddStepsToAnyHeader(var _OrderValues: Record "MOB Common Element"; _RecRef: RecordRef; var _StepsElement: Record "MOB Steps Element")
    var
        MobPrint: Codeunit "MOB Print";
    begin
        if (_RecRef.Number() in [DataBase::"Warehouse Activity Header"]) thenbegin// This example is limited to Whse. Picks

            // Break when 'Printer' step has been collected to prevent infinite loop
            if _OrderValues.HasValue('Printer') then
                exit;

            _StepsElement.Create_ListStep(1,  'Printer');
                        _StepsElement.Set_header('Label printLabel print');
                        _StepsElement.Set_listValues('   ;'  +  MobPrintMobPrint.GetMobilePrinters('Item Label 3x2', 'Item Label 3x2'));  // Allow user to select blank printer + the printers attached to this labeltemplate
            _StepsElement.Set_helpLabel('If you want a label, please select a printer.');
        end;

    end;

Select the right event

The example code is for receive.

Select another event if you are working with another function.

Filter by label (Content by label)
showLabelsfalse
max150
showSpacefalse
sorttitle
excludeCurrenttrue
cqllabel = "integrationevent" and label = "onaddstepsto" and label in ("order","orders")

Step 2:  Handle steps on posting to issue print

    // We read the collected step (printer).
    // Issue a print based on printer, label and the current context (Order Line)
    // Print engine will build a dataset   // Allow user to also select a blank printer
            _StepsElement.Set_helpLabel('If you want a label, please select a printer.');
        end;
    end;

    // Step 2: Handle Header step and issue print
    // We read the collected step (printer)
    // Issue a print based on printer, label and the current context (Order Header)
    [EventSubscriber(ObjectType::Codeunit,  Codeunit::"MOB WMS ReceiveMOB WMS Pick",  'OnPostReceiveOrderOnPostPickOrder_OnAfterPostAnyOrder',  '',  truetrue,  truetrue)]
        local procedure MyOnPostReceiveOrder MyOnPostPickOrder_OnAfterPostAnyOrder(var  _OrderValues:  Record  "MOB Common ElementMOB Common Element";   _RecRef:  RecordRef;  var  _ResultMessage:  Text)
        var
        MobPrinter        MobPrinter:  Record  "MOB PrinterMOB Printer";
        TempPrintParameter        TempPrintParameter:  Record  "MOB Print REST ParameterMOB Print REST Parameter"  temporary;
        MobPrint        MobPrint:  Codeunit  "MOB PrintMOB Print";
        MobLanguage        MobPrintBuffer:  Codeunit  "MOB WMS LanguageMOB Print Buffer";
        MobPrintBuffer:      Codeunit "MOB Print Buffer";
        PrintCommand:   PrintCommand: Text;
        begin
        // -- Prepare to Print
        // Did user select a printer?
        if         // If user selected ' ' blank printer, then exit
        if_OrderValues.GetValue('Printer')   =   '   '  then
                        exit;


        // -- Print
        // Init printer parameters
        Evaluate        // Init printer parameters
        Evaluate(TempPrintParameter.Printer,   _OrderValues.GetValue('Printer'));
        TempPrintParameter// Printer selected
        TempPrintParameter."Label-Template NameTemplate Name"  :=  'Item Label 3x2Item Label 3x2';
        //  Set parameters
        MobPrintThe label to print - consider making this configurable
        MobPrint.SetSourceRecRef(_RecRef);
        MobPrint        MobPrint.SetRequestElementsFromOrderValues(_OrderValues);
        // Perform cloud print
        if MobPrint
        if MobPrint.Run(TempPrintParameter)  then begin
                        //  Command is returned from cloud
            TempPrintParameterPrint was returned from cloud
            TempPrintParameter.GetResponseContentAsBase64Text(PrintCommand);
            // Convert the printer selected to an Address
            MobPrint            MobPrint.GetPrinterFromName(MobPrinter,  TempPrintParameterTempPrintParameter.Printer);
            // Save response to be sent in the next Mobile response
            MobPrintBuffer            MobPrintBuffer.Add(MobPrinter.Address,  PrintCommandPrintCommand);
        
        end else
                        //  If failed, append Error to ResultMessage 
            _ResultMessage := _ResultMessage + ' ' + MobLanguage.GetMessage('PRINT_FAILED'': ' + GetLastErrorText();
    end;

Select the right event

The example code is for receive.

Select another event if you are working with another function.

Filter by label (Content by label)showLabelsfalseshowSpacefalsecqllabel = "onafterpost" and label = "integrationevent"If failed, append Error to ResultMessage
           _ResultMessage := _ResultMessage + ' Print failed: ' + GetLastErrorText();
    end;

Step 3: Modify print "Dataset" (optional)

  • Use this event to modify the automatically generated dataset
, to suit your label needs.


Version History

VersionChanges
MOB5.22Necessary events introduced