Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Case

A customer wishes to start using Item NetWeight and -GrossWeight, but have currently no values registered at the Item Card. A temporary customization is to be made to start filling in these values when goods are received.

The captured values must be written to the Item Card during posting. 


Proposed solution

Two new Decimal collector steps must be added for the user to enter NetWeight and GrossWeight for the item.  The customer is using Warehouse Receipts for inbound goods always.
The customization is to be used only for a limited time, and should be isolated / easy to remove later.

NetWeight's and GrossWeight's collected at the Mobile Devices is to be stored to new fields at 

Save collected values for SalesReturnOrders to Sales Comment Line before posting (saving values for Warehouse Receipts and Purchase Orders not implemented in this example).

Note: SalesReturnOrders is for nonwarehouse locations only (ie. Cronus 'BLUE'). Sales return orders for Warehouse locations is warehouse receipts in standard BC (ie. Cronus 'WHITE').


Example

    //
    // Create new comment steps on header (displayed when posting the order)
    //
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyHeader''', true, true)]
    procedure OnGetReceiveOrderLines_OnAddStepsToAnyHeader(_RecRef: RecordRefvar _StepsElement: Record "MOB Steps Element")
    begin
        with _StepsElement do
            if _RecRef.Number() in [Database::"Warehouse Receipt Header", Database::"Purchase Header", Database::"Sales Header"] then begin
                Create_TextStep(
                    10000,                                                  // id
                    'MyCommentStep',                                        // name
                    'Comment',                                              // header
                    'Comment:',                                             // label
                    'Your optional comment about the inbound goods',        // helpLabel
                    '',                                                     // defaultvalue
                    80);                                                    // length
                Set_primaryInputMethod('Control');
                Set_optional(true);
            end;



    end;

    //
    // Save collected values prior to posting. OnBeforePostXXX-triggers will commit prior to posting, and code will need to be organized accordingly.
    //
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnPostReceiveOrder_OnBeforePostWarehouseReceipt''', true, true)]
    procedure OnPostReceiveOrder_OnBeforePostWarehouseReceipt(var _OrderValues: Record "MOB Common Element"; var _WhseReceiptHeader: Record "Warehouse Receipt Header")
    begin
        // Not implemented in this example -- see OnPostReceiveOrder_OnBeforePostSalesReturnOrder
    end;

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnPostReceiveOrder_OnBeforePostPurchaseOrder''', true, true)]
    procedure OnPostReceiveOrder_OnBeforePostPurchaseOrder(var _OrderValues: Record "MOB Common Element"; var _PurchHeader: Record "Purchase Header")
    begin
        // Not implemented in this example -- see OnPostReceiveOrder_OnBeforePostSalesReturnOrder
    end;

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnPostReceiveOrder_OnBeforePostSalesReturnOrder''', true, true)]
    procedure OnPostReceiveOrder_OnBeforePostSalesReturnOrder(var _OrderValues: Record "MOB Common Element"; var _SalesReturnHeader: Record "Sales Header")
    var
        SalesCommmentLine: Record "Sales Comment Line";
        CollectedComment: Text;
    begin
        CollectedComment := _OrderValues.GetValue('MyCommentStep');
        if CollectedComment <> '' then
            ReplaceSalesCommentLine(_SalesReturnHeader, 'MOBILEWMS', CopyStr(CollectedComment, 1, MaxStrLen(SalesCommmentLine.Comment)));
    end;

    //
    // Local helper functions
    //
    local procedure ReplaceSalesCommentLine(_SalesHeader: Record "Sales Header"; _Code: Code[10]; _Comment: Text[80])
    var
        SalesCommmentLine: Record "Sales Comment Line";
        NextLineNo: Integer;
    begin
        with SalesCommmentLine do begin
            // Remove all existing comments for the _Code
            _SalesHeader.TestField("No.");
            SetRange("Document Type", _SalesHeader."Document Type");
            SetRange("No.", _SalesHeader."No.");
            SetRange("Document Line No.", 0);
            SetRange(Code, _Code);
            DeleteAll();

            // Find next LineNo
            SetRange(Code);
            if FindLast() then
                NextLineNo := "Line No." + 10000
            else
                NextLineNo := 10000;

            // Init and insert the comment line
            Init();
            "Document Type" := _SalesHeader."Document Type";
            "No." := _SalesHeader."No.";
            Code := _Code;
            "Line No." := NextLineNo;
            Date := Today();
            Comment := _Comment;
            Insert();
        end;
    end;

  • No labels