Use this event to
Excerpt |
---|
Handle Custom Registration Type for Adhoc PostRegistrationConfiguration Document Type. Data from Xml Post-Request is provided as input parameter tables and be used/iterated with no use of Xml. |
...
Template
...
// Always return a response text to the front-end
Status := 'OK';
MOBToolbox.CreateSimpleResponse(_XMLResponseDoc, Status);
// Return that this registration type was handled
_IsHandled := true;
end;
end;
Example
Use this event to
Excerpt |
---|
Handle custom Unplanned Functions business logic. |
This event is triggered when
- Header has been accepted
- Steps has been collected
The request is provided as input tables and be accessed/iterated.
Including :
- Header Fields values
- Collected Steps values
- Current Registrations
(if your Unplanned is called from a Planned Functions e.g. Picked Order lines)
Supersedes OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml
Template 01 - Subscribe only to mandatory parameters
// [Template] 01 - Subscribe only to mandatory parameters (excluded _CurrentRegistration, _SuccessMessage and _RegistrationTypeTracking)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc RegistrMOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationTypeAsXmlOnPostAdhocRegistrationOnCustomRegistrationType', '', true true, true true)]
local procedure OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml(var _XMLRequestDoc: XmlDocument; var _XMLResponseDoc: XmlDocument; OnPostAdhocRegistrationOnCustomRegistrationType(_RegistrationType: Text; var _RegistrationTypeTrackingRequestValues: Text[200] Record "MOB NS Request Element"; var _IsHandled: Boolean)
var
MOBToolbox: Codeunit "MOB Toolbox";
Status: Text;
begin
if _RegistrationType begin
if _RegistrationType = 'SetWhseClassCodeMyCustomRegistrationType' then begin
if // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
if _IsHandled then
exit; Status := PostSetWhseClassCodeRegistration(_XMLRequestDoc, _RegistrationTypeTracking);
MOBToolbox.CreateSimpleResponse(_XMLResponseDoc, Status);
_IsHandled := true;
end;
end;
procedure PostSetWhseClassCodeRegistration(_XMLRequestDoc: XmlDocument; var _ReturnRegistrationTypeTracking: Text[200]): Text[60];
var
Item: Record Item;
MobXMLMgt: Codeunit "MOB XML Management";
MobToolbox: Codeunit "MOB Toolbox";
MobWMSToolbox: Codeunit "MOB WMS Toolbox";
MobWmsLanguage: Codeunit "MOB WMS Language";
XMLRequestNode: XmlNode;
XMLRequestDataNode: XmlNode;
XMLParameterNode: XmlNode;
XMLNodesList: XMLNodeList;
ItemNumber: Code[20];
i: Integer;
WhseClassCode: Code[10];
begin
// Extract any parameters from the XML
// The parameters are located in the <requestData> element
MobXMLMgt.GetDocRootNode(_XMLRequestDoc, XMLRequestNode);
MobXMLMgt.FindNode(XMLRequestNode, MobWMSToolbox."CONST::requestData"(), XMLRequestDataNode);
// Loop over the registration values. We don't know which values will be present because it is configurable
// The values are added to the relevant journal if they have been registered on the mobile device
MobXMLMgt.GetNodeChildNodes(XMLRequestDataNode, XMLNodesList);
for i := 1 to XMLNodesList.Count() do begin
MobXMLMgt.GetListItem(XMLNodesList, XMLParameterNode, (i)); // AL = 1 based index
case MobXMLMgt.GetNodeName(XMLParameterNode) of
'ItemNumber':
ItemNumber := MobWMSToolbox.GetItemNumber(MOBToolbox.ReadMisc(MobXMLMgt.GetNodeInnerText(XMLParameterNode)));
'WhseClassCode':
WhseClassCode := MobXMLMgt.GetNodeInnerText(XMLParameterNode);
end;
end;
_ReturnRegistrationTypeTracking := 'SetWhseClassCode: ' +
Item.TableCaption() + ' ' +
ItemNumber + ' ' +
Item.FieldCaption("Warehouse Class Code") + ' ' +
WhseClassCode;
// Perform the posting
if not Item.GET(ItemNumber) then
ERROR(STRSUBSTNO(MobWmsLanguage.GetMessage('ITEM_EXIST_ERR'), ItemNumber));
if WhseClassCode <> Item."Warehouse Class Code" then begin
Item.Validate("Warehouse Class Code", WhseClassCode);
Item.Modify(true);
end;
exit(STRSUBSTNO('Warehouse Class Code set for %1', ItemNumber));
end; exit;
// Handle _RequestValues here
// ....
_IsHandled := true;
end;
end;
Template 02 - Subscribe to all parameters
// [Template] 02 - Subscribe to all parameters
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType', '', true, true)]
local procedure T02OnPostAdhocRegistrationOnCustomRegistrationType(_MessageId: Guid; _RegistrationType: Text; var _RequestValues: Record "MOB NS Request Element"; var _CurrentRegistrations: Record "MOB WMS Registration"; var _SuccessMessage: Text; var _RegistrationTypeTracking: Text; var _IsHandled: Boolean)
var
MobDocQueue: Record "MOB Document Queue";
begin
if _RegistrationType = 'MyCustomRegistrationType' then begin // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
if _IsHandled then
exit;
// Handle _RequestValues here
// ....
// Optional: Read MobDocQueue to i.e. read device id
MobDocQueue.GetByGuid(_MessageId, MobDocQueue);
_SuccessMessage := 'My custom success message';
_RegistrationTypeTracking := 'My custom description for the document queue (column RegistationType';
_IsHandled := true;
end;
end;
Example (1) - Iteration of _RequestValues and _CurrentRegistrations
// [Example] 01 - Sample iteration of _RequestValues and _Currentegistrations
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType', '', true, true)]
local procedure Ex01OnPostAdhocRegistrationOnCustomRegistrationType(_RegistrationType: Text; var _RequestValues: Record "MOB NS Request Element"; var _CurrentRegistrations: Record "MOB WMS Registration"; var _IsHandled: Boolean)
begin
if _RegistrationType = 'MyCustomRegistrationType' then begin // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
if _IsHandled then
exit;
// Sample iteration of requestData (excluding <Order>-element)
if _RequestValues.FindFirst() then
repeat
until _RequestValues.Next() = 0;
// Sample iteration of "current" registrations from <Order>-element (snapshot of unposted Registrations as they look right now when an adhoc registration is triggered)
// CurrentRegistration's is included only if attribute sendRegistrationData="Order"|"OrderLine" was used from application.cfg
if _CurrentRegistrations.FindFirst() then
repeat
until _CurrentRegistrations.Next() = 0;
_IsHandled := true;
end;
end;
Example (2) - Read values from _RequestValues (and, subscribing only to some parameters (excluded _CurrentRegistrations and _SuccessMessage)
// [Example] 02 - Read values from _RequestValues - and: subscribing only to some parameters (excluded _CurrentRegistrations and _SuccessMessage)
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType', '', true, true)]
local procedure Ex02OnPostAdhocRegistrationOnCustomRegistrationType(_RegistrationType: Text; var _RequestValues: Record "MOB NS Request Element"; var _RegistrationTypeTracking: Text; var _IsHandled: Boolean)
begin
if (_RegistrationType = 'MyCustomUnplannedProdConsumption') and (not _IsHandled) then begin
_RegistrationTypeTracking := PostUnplannedProdConsumption(_RequestValues);
_IsHandled := true;
// No SuccessMessage is returned -> default message is automatically added to the XmlResponse
end;
end;
local procedure PostUnplannedProdConsumption(var _RequestValues: Record "MOB NS Request Element") _RegistrationTypeTracking: Text
var
ProdOrderNo: Code[20];
ProdOrderLineNo: Integer;
ItemNo: Code[20];
VariantCode: Code[10];
UnitOfMeasureCode: Code[10];
Qty: Decimal;
begin
// Parse values from Request
ProdOrderNo := _RequestValues.GetValue('ProdOrder').SubString(1, MaxStrLen(ProdOrderNo));
ProdOrderLineNo := _RequestValues.GetValueAsInteger('ProdOrderLineNo', true);
ItemNo := _RequestValues.GetValue('Item').Substring(1, MaxStrLen(ItemNo));
VariantCode := _RequestValues.GetValue('Variant', false).Substring(1, MaxStrLen(VariantCode)); // GetValue(.., false) = no error if not exists
UnitOfMeasureCode := _RequestValues.GetValue('UoM', false).Substring(1, MaxStrLen(UnitOfMeasureCode));
Qty := _RequestValues.GetValueAsDecimal('Qty');
//
// Find the Prod. Order Line
//
// ... not implemented in this example
//
// Create Item Journal Line and post
//
// ... not implemented in this example
// Return information about this request/response to be displayed at the Mobile Document Queue
_RegistrationTypeTracking := StrSubstNo('%1 - %2 - %3 - %4 - %5 - %6', ProdOrderNo, ProdOrderLineNo, ItemNo, VariantCode, Format(Qty), UnitOfMeasureCode);
end;
Filter by label (Content by label) | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Version History
Version | Changes |
---|---|
MOB5.15 | Introduced |
MOB5.17 | New parameter _MessageId |
MOB5.24 | New helper methods for GetValueAsInteger and GetValueAsDecimal |