Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Excerpt

Add Steps to be displayed during a line registration on planned functions

...

Line steps are displayed on every line. Unless you modify Step dynamically for change the steps visibility.

Step 1: Define Line Step(s)


Select the event based on which functionality you are modifying.

...

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
excerptTypesimple
cqllabel = "onaddstepstoanyline" and label = "integrationevent"



Add code to OnGetReferenceData_OnAddRegistrationCollectorConfigurations the to create your step(s).     //  Step 1: Define steps

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddRegistrationCollectorConfigurations''', false, false)]
    local procedure MyOnGetReferenceData_OnAddRegistrationCollectorConfigurations(var _Steps: Record "MOB Steps Element")
    begin
        _Steps.InitConfigurationKey('MyCustomPickLineStep');
        _Steps.Create_TextStep(10'MyTextStep''Header text''Label text''Help text''Default text'30);
    end;
 

Step 2: Add steps to Pick-function

Step 1: Define steps. In this example, the step is added to the Pick Order lines and the value from this step is then added directly to the Sales Comment Line, in the Sales Order. 

Step 1: Define Line Step(s)

Using OnGetPickOrderLines_OnAddStepsToAnyLine to add the steps to Pick Order Lines


   [EventSubscriber(ObjectType::Codeunit,

...

Codeunit::"

...

MOB WMS Pick",

...

'OnGetPickOrderLines_OnAddStepsToAnyLine',

...

'',

...

true,

...

true)]

...

   local

...

procedure

...

OnGetPickOrderLines_OnAddStepsToAnyLine(_RecRef:

...

RecordRef;

...

var

...

_BaseOrderLineElement

...

: Record"MOB Ns BaseDataModel Element"; var _Steps: Record"MOB Steps Element")

...

     begin

...

        _Steps.Create_

...

TextStep(10, 'MyTextStep', 'Header text', 'Label text', 'Help text', 'Default text', 30);

...

    end;

Changes to Reference Data are only visible after logging out/in

You should now see the steps you have added

   

Step

...

2: Store and Process the data

Subscribe to an OnHandle event OnPostPickOrder_OnHandleRegistrationForAnyLine

...

In this example, we store the step text value as a Sales Comment Line


    //  Step 3:  Store collected step valuesStep 2:  Store collected step values

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Pick", 'OnPostPickOrder_OnHandleRegistrationForAnyLine''', true, true)]
    local procedure OnPostPickOrder_OnHandleRegistrationForAnyLine(var _Registration: Record "MOB WMS Registration"; var _RecRef: RecordRef)
    var
        SalesLine: Record "Sales Line";
        MyTextValue: Text;
    begin
        MyTextValue := _Registration.GetValue('MyTextStep');

        if MyTextValue = '' then
            exit;
        
    // Get the source document line as this event if for "Any line". Choose a more specific event if you only need to handle one document type 
        if _RecRef.Number = Database::"Sales Line" then begin
            _RecRef.SetTable(SalesLine);
            AddAsCommentLine(SalesLine, 'FromMobile', CopyStr(MyTextValue, 180));
        end;
        
     // Note: You might also need to subscribe to Standard Posting Routines to process your new data
    end;

    local procedure AddAsCommentLine(_SalesLine: Record "Sales Line"; _Code: Code[10]; _Comment: Text[80])
    var
        SalesCommmentLine: Record "Sales Comment Line";
        NextLineNo: Integer;
    begin
                // Find next LineNo
        SalesCommmentLine.SetRange("Document Type", _SalesLine."Document Type");
        SalesCommmentLine.SetRange("No.", _SalesLine."Document No.");
        if SalesCommmentLine.FindLast() then
            NextLineNo := SalesCommmentLine."Line No." + 10000
        else
            NextLineNo := 10000;
        
       // Init and insert the comment line
        SalesCommmentLine.Init();
        SalesCommmentLine."Document Type" := _SalesLine."Document Type";
        SalesCommmentLine."No." := _SalesLine."Document No.";
        SalesCommmentLine."Document Line No." := _SalesLine."Line No.";
        SalesCommmentLine.Code := _Code;
        SalesCommmentLine."Line No." := NextLineNo;
        SalesCommmentLine.Date := Today();
        SalesCommmentLine.Comment := _Comment;
        SalesCommmentLine.Insert();
    end;