Versions Compared

Key

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

Description

...

    // [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)]
    local 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
        ifnot _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;

...