Versions Compared

Key

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

Description

Excerpt

You want to modify a label template by adding data to it



In this example, we will be adding these fields to an Item Label.

  • Gross Weight
  • Warehouse Class Code

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
titleSee also (video)
excludeCurrenttrue
cqllabel = "bc" and label = "video" and label = "print" and label in ("howto","case")

In this example, we will be adding these fields to an Item Label.

...

Dataset

When an Item Label is printed it is already based on an Item/Item Reference.

...


    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Print", 'OnPrintLabel_OnAfterPopulateDataset', '', true, true)]
    local procedure Ex01OnPrintLabel_OnAfterPopulateDataset(_TemplateName: Text[50]; _SourceRecRef: RecordRef; var _Dataset: Record "MOB Common Element")
    var
        Item: Record Item;
    begin
        // Only relevant for Item labels
        // Item labels are always called with an RecordRef for "Item". Else exit
        if _SourceRecRef.Number = database::Item then
            _SourceRecRef.SetTable(Item)
        else
            exit;

        // Set extrainfo fields and their labels, in the dataset
        _Dataset.SetValue('ExtraInfo01', Item."Gross Weight");
        _Dataset.SetValue('ExtraInfo01_Label', Item.FieldCaption("Gross Weight"));

        _Dataset.SetValue('ExtraInfo02', Item."Warehouse Class Code");
        _Dataset.SetValue('ExtraInfo02_Label', Item.FieldCaption("Warehouse Class Code"));
    end;

Step 3

Verify data is sent to the cloud

...