OnLiveUpdateOnCustomDocumentType
Use this event to
Handle existing or new 'LiveUpdate' document types.
Description
You can use this feature to have the registration data continuously sent to BC, every time the user performs registration. See Register Realtime Quantity (Liveupdate)
Use this event to overwrite/replace existing behavior or handle new custom types.
See also
To only handle the reading of values, see OnSaveRealtimeRegistrationValue
Template
// [Template]
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS LiveUpdate", 'OnLiveUpdateOnCustomDocumentType', '', true, true)]
local procedure OnLiveUpdateOnCustomDocumentType(_DocumentType: Text; var _TempRealtimeRegistrations: Record "MOB Realtime Reg Qty."; var _ResponseElement: Record "MOB NS Resp Element"; _ClearOrderLines: Boolean; var _RegistrationTypeTracking: Text; var _IsHandled: Boolean)
begin
end;
Example
Overwrite standard "RegisterRealtimeQuantity". This example is the same as standard, but it can be viewed as a template for your own custom implementation of LiveUpdate.
// [Example]
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS LiveUpdate", 'OnLiveUpdateOnCustomDocumentType', '', true, true)]
local procedure Ex01OnLiveUpdateOnCustomDocumentType(_DocumentType: Text; var _TempRealtimeRegistrations: Record "MOB Realtime Reg Qty."; var _ResponseElement: Record "MOB NS Resp Element"; _ClearOrderLines: Boolean; var _RegistrationTypeTracking: Text; var _IsHandled: Boolean)
var
MobRealtimeRegQty: Record "MOB Realtime Reg Qty.";
begin
// Make sure we only handle the RegisterRealtimeQuantity
if _DocumentType <> 'RegisterRealtimeQuantity' then
exit;
if not _TempRealtimeRegistrations.FindFirst() then
exit;
// -- Clear all quantities for entire order (Request is "ClearOrderLines")
if _ClearOrderLines then begin
_RegistrationTypeTracking := 'ClearOrderLines' + ' ' + _TempRealtimeRegistrations.Type + ' ' + _TempRealtimeRegistrations."Order No.";
_TempRealtimeRegistrations.TestField("Line No.", ''); // Line no. is blank because we want to delete all lines for entire order
DeleteRealtimeQuantity(_TempRealtimeRegistrations);
// Success = exit
_IsHandled := true;
exit;
end;
// -- Save line quantities
_RegistrationTypeTracking := _TempRealtimeRegistrations.Type + ' ' + _TempRealtimeRegistrations."Order No.";
// Clear previous registrations for this line, since request contains all current line registrations
_TempRealtimeRegistrations.TestField("Line No.");
DeleteRealtimeQuantity(_TempRealtimeRegistrations);
// Loop and Insert as Realtime registration if quantity is present
_TempRealtimeRegistrations.SetFilter(Quantity, '>0');
if _TempRealtimeRegistrations.FindSet() then
repeat
// Copy temp record and insert
MobRealtimeRegQty := _TempRealtimeRegistrations;
MobRealtimeRegQty."Registration No." := 0; // Autoincremented when inserted
MobRealtimeRegQty.Insert(true);
until _TempRealtimeRegistrations.Next() = 0;
// Success
_IsHandled := true;
end;
local procedure DeleteRealtimeQuantity(_Registrations: Record "MOB Realtime Reg Qty.")
var
MobRealtimeRegQty: Record "MOB Realtime reg Qty.";
begin
MobRealtimeRegQty.SetRange(Type, _Registrations.Type);
MobRealtimeRegQty.SetRange("Order No.", _Registrations."Order No.");
if _Registrations."Line No." <> '' then // Delete only for current line, not entire order
MobRealtimeRegQty.SetRange("Line No.", _Registrations."Line No.");
MobRealtimeRegQty.DeleteAll();
end;
More examples
There are no items with the selected labels at this time.
Version History
Version | Changes |
---|---|
MOB5.24 | Introduced |