/
Case: Collect ExpirationDate in a custom text step
Case: Collect ExpirationDate in a custom text step
Case
Collect ExpirationDate in a custom text step.
Proposed solution
Collect ExpirationDate in a custom text step in format YYYYMMDD when items are received:
Disable standard Expiration Date step (RegisterExpirationDate) due to this always being validated as date format, then replace it with a new custom step that takes a text value instead of a date value.
When saving RegistrationData, the new custom ExpirationDate should be used if it exists. "Expiration Date" will be used by Mobile WMS posting functions with no further changes.
Example
// For Receive Order Lines, If RegisterExpirationDate is set to true for the item, set it to false.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyLine', '', true, true)]
local procedure OnGetReceiveOrderLines_OnAfterAddStepsOnAnyLine(_RecRef: RecordRef; var _BaseOrderLineElement: Record "MOB Ns BaseDataModel Element")
begin
if _BaseOrderLineElement.Get_RegisterExpirationDate() = 'true' then
_BaseOrderLineElement.Set_RegisterExpirationDate(false); // Disable the standard (date format) expiration date step
end;
// Create new custom text step called "MyExpirationDate"
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyLine', '', true, true)]
local procedure My01OnGetReceiveOrderLines_OnAddStepsToAnyLine(_RecRef: RecordRef; var _BaseOrderLineElement: Record "MOB NS BaseDataModel Element"; var _Steps: Record "MOB Steps Element")
begin
_Steps.Create_TextStep(10000, 'MyExpirationDate');
_Steps.Set_header('Expiration Date');
_Steps.Set_label('Expiration Date: ');
_Steps.Set_helpLabel('Set Expiration Date');
end;
// Save the value from the custom text step "MyExpirationDate" to the Expiration Date field in Mobile WMS Registration list
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Toolbox", 'OnSaveRegistrationValue', '', true, true)]
local procedure OnSaveRegistrationValue(_Path: Text; _Value: Text; var _MobileWMSRegistration: Record "MOB WMS Registration"; var _IsHandled: Boolean)
var
Day: Integer;
Year: Integer;
Month: Integer;
begin
if _Path <> 'MyExpirationDate' then
exit;
if _Value <> '' then begin
Evaluate(Year, CopyStr(_Value, 1, 4)); // Format YYYYMMDD
Evaluate(Month, CopyStr(_Value, 5, 2));
Evaluate(Day, CopyStr(_Value, 7, 2));
_MobileWMSRegistration."Expiration Date" := DMY2Date(Day, Month, Year);
end else
_MobileWMSRegistration."Expiration Date" := 0D;
_IsHandled := true;
end;
Version History
Version | Changes |
---|---|
MOB5.11 | Neccessary events introduced |