- Created by Johannes Sebastian Nielsen, last modified on Jul 06, 2023
This article was written for legacy versions of Mobile WMS extension (MOB.23 - MOB5.38).
The MobTrackingSetup framwork was introduced in MOB5.39 and this article was updated accordingly, see Case: Print muliple labels with unique lot numbers
Requirements
Mobile WMS Extension version MOB5.23
Android App version 1.5.9
Case
Option to generate and print multiple unique labels
Proposed solution
You are happy with the ability to print a label based on a desired Lot number, but:
The process can be optimized when mulitple labels are needed.
So you want to the system to automatically generate a number of labels and assign them unique Lot numbers.
Use case
- The user enters Lot when asked during printing = One label
OR - The user Leaves the Lot step = blank
- This triggers another step that asks for how many unique labels should be generated = Multiple unique labels
- This triggers another step that asks for how many unique labels should be generated = Multiple unique labels
This solution could be a good fit for:
- Production Output
- Warehouse Receipts
The solution can be modifed for use with Serial No.
Step 1: Allow for blank Lot -step value
In order to determine when to print multiple labels, we must modify the existing Lot -step using OnLookupOnPrintLabel_OnAfterAddStepForTemplate
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Print", 'OnLookupOnPrintLabel_OnAfterAddStepForTemplate', '', true, true)]
local procedure OnLookupOnPrintLabel_OnAddStepsForTemplate(_TemplateName: Text[50]; _SourceRecRef: RecordRef; var _Step: Record "MOB Steps Element"; var _Dataset: Record "MOB Common Element")
begin
if _Step.Get_name() = 'LotNumber' then
_Step.Set_optional(true); // Now optional = Blank is now allowed
end;
entral : NTW-1677-docs-add-case-for-multilpe-labels
Step 2: Insert Step to ask user for the number of unique labels to generate
- Since PrintLabel is is an Unplanned Function we can use Return steps on Post to insert a new step called "UniqueLabels".
- This step will allow us to determine when and how many labels to generate
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistration_OnAddSteps', '', true, true)]
local procedure MyOnPostAdhocRegistration_OnAddSteps(_RegistrationType: Text; var _RequestValues: Record "MOB NS Request Element"; var _Steps: Record "MOB Steps Element"; var _RegistrationTypeTracking: Text)
var
MobReservationMgt: Codeunit "MOB Reservation Mgt.";
MobWmsToolbox: Codeunit "MOB WMS Toolbox";
RegisterSerialNumber: Boolean;
RegisterLotNumber: Boolean;
RegisterExpirationDate: Boolean;
begin
// Only handle printing
if _RegistrationType <> MobWmsToolbox."CONST::PrintLabelTemplate"() then
exit;
// Step has already been added and user has filled it out
if _RequestValues.GetValueAsInteger('UniqueLabels') > 0 then
exit;
// Check whether Lot-step is to be expected
MobReservationMgt.DetermineSpecificTrackingFromItemNo(_RequestValues.Get_ItemNumber(), RegisterSerialNumber, RegisterLotNumber, RegisterExpirationDate);
// Create step to determine how many labels to generate
if RegisterLotNumber and (_RequestValues.GetValue('LotNumber') = '') then begin
_Steps.Create_IntegerStep(99, 'UniqueLabels', 'How many unique labels do you want?');
_Steps.Set_helpLabel('You did not enter Lot No. How many labels should be generated?');
_Steps.Set_minValue(1);
end;
end;
Step 3: Generate multiple labels
Now that we have collected "UniqueLabels" -step, we must use OnPrintLabel_OnAfterPopulateDataset to:
- Lookup Item and No. series
- Get next number from No. Series
- Generate the labels with the desired Lot number
[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 _RequestValues: Record "MOB NS Request Element")
var
Item: Record Item;
NoSeriesManagement: Codeunit NoSeriesManagement;
UniqueLabels: Integer;
i: Integer;
begin
// Making sure we only handle the right label-template
// Change this name to your own label-template
if not _TemplateName.Contains('Item Label') then
exit;
// Get item being printed
Item.Get(_RequestValues.Get_ItemNumber(true));
Item.TestField("Lot Nos."); // Must have no series
// No of labels (collected from user)
UniqueLabels := _RequestValues.GetValueAsInteger('UniqueLabels');
for i := 0 to UniqueLabels do begin
if i > 1 then // Create additional labels/datasets for the remaining LotNumbers in the sequence
_Dataset.InitFromCommonElement(_Dataset);
_Dataset.SetValue('LabelNumber', i);
_Dataset.SetValue('LotNumber', NoSeriesManagement.GetNextNo(Item."Lot Nos.", WorkDate(), true));
end;
end;
The result
Note the incremented Lot numbers