Warning | ||
---|---|---|
| ||
This event is deprecated and will be removed in 2021article was written for legacy versions of Mobile WMS (MOB.11 - MOB5.13). New events was introduced in MOB5.14 and the article was updated accordingly, see Case: Add Line Steps for Warehouse Receipts |
...
Standard CRONUS Location 'WHITE' can be used for testing the customization.
Example
tableextension 50200 "DEMO Warehouse Receipt Line" extends "Warehouse Receipt Line"
{
fields
{
field(50200; "DEMO Captured NetWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured NetWeight';
DataClassification = CustomerContent;
}
field(50201; "DEMO Captured GrossWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured GrossWeight';
DataClassification = CustomerContent;
}
}
}
tableextension 50201 "DEMO Posted Whse. Receipt Line" extends "Posted Whse. Receipt Line"
{
fields
{
field(50200; "DEMO Captured NetWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured NetWeight';
DataClassification = CustomerContent;
}
field(50201; "DEMO Captured GrossWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured GrossWeight';
DataClassification = CustomerContent;
}
}
}
codeunit 50201 "DEMO Receive Weight Ext v5.11"
{
//
// Create new RegistrationCollectorConfiguration-Key in reference data with two steps named: "CustomGrossWeightGrams" and "CustomNetWeightGrams"
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAfterAddRegistrationCollectorConfigurationsAsXml', '', true, true)]
local procedure OnGetReferenceData_OnAfterAddRegistrationCollectorConfigurationsAsXml(var _XmlResponseData: XmlNode)
var
MobXmlMgt: Codeunit "MOB XML Management";
XmlConfigurationNode: XmlNode;
XmlKeyNode: XmlNode;
XmlValueNode: XmlNode;
XmlCDataSection: XmlCdata;
begin
// Add the mandatory nodes
MobXmlMgt.AddElement(_XmlResponseData, 'Configuration', '', '', XmlConfigurationNode);
MobXmlMgt.AddElement(XmlConfigurationNode, 'Key', 'CustomWReceiveSteps', '', XmlKeyNode);
MobXmlMgt.AddElement(XmlConfigurationNode, 'Value', '', '', XmlValueNode);
// Add the CDATA section to the Value-Node
XmlCDataSection := GetOrderLineExtraInfoCDataSection();
MobXMLMgt.NodeAppendCData(XmlValueNode, XmlCDataSection);
end;
local procedure GetOrderLineExtraInfoCDataSection() XmlCDataSection: XmlCdata
var
MobXmlMgt: Codeunit "MOB XML Management";
MobConfTools: Codeunit "MOB WMS Conf. Tools";
DummyXmlDocument: XmlDocument;
begin
// Create an empty CDATA section to add the registrationCollectorConfiguration XML to
MobXmlMgt.NodeCreateCData(DummyXmlDocument, XmlCDataSection, '');
// Create the start tags of the configuration xml. These must be closed afterwards.
MobXMLMgt.NodeAppendCDataText(XmlCDataSection, '<registrationCollectorConfiguration>');
MobXMLMgt.NodeAppendCDataText(XmlCDataSection, '<steps>');
// Add the actual steps
MobConfTools.RC_Std_Parms(10000, 'CustomGrossWeightGrams', 'Gross Weight (Grams)', 'Gross Weight (Grams):', 'Gross Weight in Grams per Base Unit of Measure');
MobConfTools.RC_Decimal_CData(XmlCDataSection, 0, 0, 100000, 6, true);
MobConfTools.RC_Std_Parms(20000, 'CustomNetWeightGrams', 'Net Weight (Grams)', 'Net Weight (Grams):', 'Net Weight in Grams per Base Unit of Measure');
MobConfTools.RC_Decimal_CData(XmlCDataSection, 0, 0, 100000, 6, true);
MobXMLMgt.NodeAppendCDataText(XmlCDataSection, '</steps>');
MobXMLMgt.NodeAppendCDataText(XmlCDataSection, '</registrationCollectorConfiguration>');
exit(XmlCDataSection);
end;
//
// Add steps referenced by new RegistrationCollectorConfiguration-Key to line steps collectors
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyLine', '', true, true)]
procedure OnGetReceiveOrderLines_OnAddStepsToAnyLine(_RecRef: RecordRef; var _BaseOrderLineElement: Record "MOB Ns BaseDataModel Element")
begin
with _BaseOrderLineElement do
// MOB5.11
// Currently the Android Mobile App supports only one "RegisterExtraInfo"-node (one extra RegistrationCollectorConfigurationKey).
// The last subscriber to OnGetReceiveOrderLines_OnAfterAddStepsByReferenceDataKey must set a <RegisterExtraInfo>-key that includes steps for all previous subscribers.
// This is only possible by knowing what other customizations is done and manually create a new RegistrationCollectorConfigurationKey that includes all steps.
//
// In this demo we expect to be only subscriber and throw an error if earlier subscribtions exists by including optional _ErrorIfAlreadyCreated parameter.
// We cannot test if later subcribers is overriding this value we set.
Create_StepsByReferenceDataKey('CustomWReceiveSteps', true);
end;
//
// Handle new step input values by WhseReceiptLine (move captured values to new fields at Whse. Receipt Line)
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnPostReceiveOrder_OnHandleRegistrationForWarehouseReceiptLine', '', true, true)]
procedure OnPostReceiveOrder_OnHandleRegistrationForWarehouseReceiptLine(var _Registration: Record "MOB WMS Registration"; var _WhseReceiptLine: Record "Warehouse Receipt Line")
var
MobWmsToolbox: Codeunit "MOB WMS Toolbox";
RegistrationXmlText: Text;
begin
// Demo: Show content of the "Registration XML" blob -- not needed for the processing below (useful for debugging)
RegistrationXmlText := _Registration.GetRegistrationXmlAsText();
// Parse the xml WmsRegistration by name of the steps declared in GetOrderLineExtraInfoCDataSection() and save value to new fields at WhseReceiptLine
// Includes optional parameter _ErrorIfNotExists since we unconditially expect these two nodes to exist at all line registrations
_WhseReceiptLine."DEMO Captured NetWeight" := MobWmsToolbox.Text2Int(_Registration.GetValue('CustomNetWeightGrams', true));
_WhseReceiptLine."DEMO Captured GrossWeight" := MobWmsToolbox.Text2Int(_Registration.GetValue('CustomGrossWeightGrams', true));
end;
//
// Push new fields at Warehouse Activity Line to Item card using standard posting event
// Using this standard event ensures data written to Item is within same commit at Whse Receipt Line posting
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Whse.-Post Receipt", 'OnBeforePostSourceDocument', '', true, true)]
procedure OnWhsePostReceiptOnBeforePostSourceDocument(var WhseRcptLine: Record "Warehouse Receipt Line"; PurchaseHeader: Record "Purchase Header"; SalesHeader: Record "Sales Header"; TransferHeader: Record "Transfer Header")
var
Item: Record Item;
begin
if not (Item.Get(WhseRcptLine."Item No.") and ((WhseRcptLine."DEMO Captured NetWeight" <> 0) or (WhseRcptLine."DEMO Captured GrossWeight" <> 0))) then
exit;
UpdateItemWeights(Item, WhseRcptLine."DEMO Captured NetWeight", WhseRcptLine."DEMO Captured GrossWeight");
Item.Modify();
end;
local procedure UpdateItemWeights(var _Item: Record Item; _NetWeightGrams: Integer; _GrossWeightGrams: Integer)
var
ConversionFactor: Decimal;
begin
// Conversion factor between registrered unit (grams) and item card unit (kg) -- hardcoded for simplification
ConversionFactor := 1000;
// Update item card if new values was provided in the input steps
if _GrossWeightGrams > 0 then
_Item."Gross Weight" := _GrossWeightGrams / ConversionFactor;
if _NetWeightGrams > 0 then
_Item."Net Weight" := _NetWeightGrams / ConversionFactor;
end;
}
Testing your solution
- Register a Warehouse Receipt at a Mobile Device. Two new line steps for NetWeight and GrossWeight should appear. Add both Weights for an item and post the Receipt.
- Run table browser for Posted Whse. Receipt Line (table no. 7319). Your new values should be visible at latest posted receipt:
- Run table browser for Item (table no. 27). Your new values should be recorded at the Item you registered/posted:
...