Use this event to

Modify label data before transfer to the Cloud Print Service

  • Make sure you are only handling the desired template
  • Use GetValue/SetValue to modify the dataset

See also:

Customize Labels

Standard Label Template Designs


    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB Print", 'OnPrintLabel_OnAfterPopulateDataset''', true, true)]
    local procedure OnPrintLabel_OnAfterPopulateDataset(_TemplateName: Text[50]; _SourceRecRef: RecordRefvar _Dataset: Record "MOB Common Element")

  • _TemplateName: 
    • Name of the template to handle
  • _SourceRecRef: 
    • A RecordRef to the context the print is called from.
    • I.e. Sales Order Line, Warehouse Receipt Line, Purchase Order Return Line, Warehouse Activity(Pick, Put-away) etc.
  • _Dataset: 
    • The Print Dataset . Use the dataset and determine which steps you want to collect

Example 1: Modify labels on Item Label

    // [Example 01]
    // Read the Item No. from Dataset and change it 
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB Print", 'OnPrintLabel_OnAfterPopulateDataset''', true, true)]
    local procedure Ex01OnPrintLabel_OnAfterPopulateDataset(_TemplateName: Text[50]; _SourceRecRef: RecordRefvar _Dataset: Record "MOB Common Element")

        // Making sure we only handle our own Label-Template
        if _TemplateName <> 'My custom Label-Template' then

        // Read the Item No. from Dataset and change it 
        // Item No. could have been collected or transferred from "context"/source table, where the print action was selected by the user 
        if _Dataset.GetValue('ItemNumber''ItemA' then

Example 2: Set extra info fields and their labels

    // [Example 02]
    // Read Source record
    // Set ExtraInfo fields, their labels in dataset
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB Print", 'OnPrintLabel_OnAfterPopulateDataset''', true, true)]
    local procedure Ex03OnPrintLabel_OnAfterPopulateDataset(_TemplateName: Text[50]; _SourceRecRef: RecordRefvar _Dataset: Record "MOB Common Element")
        Item: Record Item;
        Vendor: Record Vendor;

        // Making sure we only handle our own Label-Template
        if _TemplateName <> 'Item Label 4x6' then

        // If source is "Item" = Get record from RecordRef
        if _SourceRecRef.Number = database::Item then

        // Set extrainfo fields and their labels in the Dataset
        _Dataset.SetValue('ExtraInfo01', Item.Description);

        _Dataset.SetValue('ExtraInfo02', Item.GTIN);

        _Dataset.SetValue('ExtraInfo03_Label''Purchasing Unit');
        _Dataset.SetValue('ExtraInfo03', Item."Purch. Unit of Measure");

        if Vendor.Get(item."Vendor No."then
            _Dataset.SetValue('ExtraInfo04', Vendor.Name);

        // Additional custom values can also be used on the label


More examples


Version History