Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Description

Skip collecting printer name when printing a label

Use case

If you can determine the printer based on label name, context, user name, etc. then you may skip collecting printer-step 


Modify the printer step

We hide the step and we set a default value.

This way, the value is set, but the user will not be prompted.

Using event OnLookupOnPrintReport_OnAfterAddStepForReport


    // [Example] Hide printer step, instead of collecting the value, set a (hidden) default value
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Report Print Lookup", 'OnLookupOnPrintReport_OnAfterAddStepForReport', '', true, true)]
    procedure MyOnLookupOnPrintReport_OnAfterAddStepForReport(_MobReport: Record "MOB Report"; var _RequestValues: Record "MOB NS Request Element"; _SourceRecRef: RecordRef; var _Step: Record "MOB Steps Element");
    var
        MobReportPrinter: Record "MOB Report Printer";
    begin
        // Making sure we only handle relevant label templates
        if not _MobReport."Display Name".Contains('3x2') then
            exit;

        // Making sure we only handle the relevant step
        if _Step.Get_name() <> 'ReportPrinter' then
            exit;

        // Find the printer to use
        MobReportPrinter.FindFirst();

        // Set defaultValue and hide printer-step
        _Step.Set_defaultValue(MobReportPrinter."Printer Name");
        _Step.Set_visible(false);
    end;

See also 


  • No labels