Use this event to
Excerpt |
---|
Modify the Dataset after it has been populated with context and collected step values |
Description
Should you want to modify the data of a label template (standard or custom) you can do it with this event.
- Make sure you are only handling the desired template.
- Use GetValue/SetValue to modify the dataset.
- All the values in the dataset are sent to InterForm by default.
Please inspect the Label Templates for available fields and labels to modify.
Template
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Print", 'OnPrintLabel_OnAfterPopulateDataset', '', true, true)]
procedure OnPrintLabel_OnAfterPopulateDataset(_TemplateName: Text; _SourceRecRef: RecordRef; var _Dataset: Record "MOB Common Element" temporary)
begin
end;
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 02: Modify labels