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:
Template
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Print", 'OnPrintLabel_OnAfterPopulateDataset', '', true, true)]
local procedure OnPrintLabel_OnAfterPopulateDataset(_TemplateName: Text[50]; _SourceRecRef: RecordRef; var _Dataset: Record "MOB Common Element")
begin
end;
Example 1: Modify labels on Item Label
// [Example 01]
// Read the Item No. from Dataset and change it
[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")
begin
// Making sure we only handle our own Label-Template
if _TemplateName <> 'My custom Label-Template' then
exit;
// 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
_Dataset.SetValue('ItemNumber', 'ItemB');
end;
Example 2: Set extra info fields and their labels
// [Example 02]
// Read Source record
// Set ExtraInfo fields, their labels in dataset
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Print", 'OnPrintLabel_OnAfterPopulateDataset', '', true, true)]
local procedure Ex03OnPrintLabel_OnAfterPopulateDataset(_TemplateName: Text[50]; _SourceRecRef: RecordRef; var _Dataset: Record "MOB Common Element")
var
Item: Record Item;
Vendor: Record Vendor;
begin
// Making sure we only handle our own Label-Template
if _TemplateName <> 'Item Label 4x6' then
exit;
// If source is "Item" = Get record from RecordRef
if _SourceRecRef.Number = database::Item then
_SourceRecRef.SetTable(Item);
// Set extrainfo fields and their labels in the Dataset
_Dataset.SetValue('ExtraInfo01_Label', 'Desc.');
_Dataset.SetValue('ExtraInfo01', Item.Description);
_Dataset.SetValue('ExtraInfo02_Label', 'GTIN');
_Dataset.SetValue('ExtraInfo02', Item.GTIN);
_Dataset.SetValue('ExtraInfo03_Label', 'Purchasing Unit');
_Dataset.SetValue('ExtraInfo03', Item."Purch. Unit of Measure");
_Dataset.SetValue('ExtraInfo04_Label', 'Vendor');
if Vendor.Get(item."Vendor No.") then
_Dataset.SetValue('ExtraInfo04', Vendor.Name);
// Additional custom values can also be used on the label
_Dataset.SetValue('CustomValueA', 'A');
_Dataset.SetValue('CustomValueB', 'B');
end;
More examples
-
(Legacy) Case: Print muliple labels with unique lot numbers (MOB5.23-MOB5.38) — Option to generate and print multiple unique labels
-
Case: Print Customized License Plate Contents label (Cloud Print) — Modify the column and lines on License Plate Contents.
-
Case: Print Label on Planned Function Posting (Cloud Print) — Print Label on Planned Posting, i.e. Receive, Pick, Put-away, Ship, Move etc.
-
Case: Print Label on Tote Shipping Posting (Cloud Print) — Print Label on the posting of Tote Shipping.
-
Case: Print muliple labels with unique lot numbers (Cloud Print) — Option to generate and print multiple unique labels
-
Case: Print your own ZPL labels (Cloud Print) — Print your own ZPL labels
-
Cloud Print: How to Copy a Label-Template to New — In this video, we will make a copy an existing label-template
-
Cloud Print: How to modify label-template — In this video, you will be introduced to modify the design of a label-template, using the designer.
-
Cloud Print: How to modify label-template and add data — In this video, you will be introduced to modifying the design of a label template, using the designer, and adding data using AL code.
-
How-to: Add data to label-template (Cloud Print) — You want to modify a label template by adding data to it
-
How-to: Add new/Copy a label-template (Cloud Print) — You want to add/create a custom label template with a unique design
-
How-to: Modify steps on a label-template (Cloud Print) — Modify collected steps before a Label-template is printed.
Version History
Version | Changes |
---|---|
MOB5.16 | Introduced |