Versions Compared

Key

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

Description

Excerpt

Examples of sorting Order list

...

Expand
titleSee event parameters
  • _[SourceTable]
    • The source table from where the data is read.
      • This parameter is only for reference.
      • It is not to be modified and filters does not have any effect.

  • _BaseOrderElement
    Helper functions to identify and manipulate the Order-element

    • Get:
      • Get_Value
        • Get any value already set on the element
      • Get_BackendID
        • Get Order No.
      • Get_RecRefFromReferenceID
        • Get RecordRef to the Order
    • Set:

...

  • Change key to existing field "Item no."
  • Change sorting direction to "Descending"

[EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Put Away", 'OnGetPutAwayOrderLines_OnAfterSetCurrentKey''', true, true)]
procedure OnGetPutAwayOrderLines_OnAfterSetCurrentKey(var _BaseOrderLineElementView: Record "MOB Ns BaseDataModel Element")
begin
     _BaseOrderLineElementView.SetCurrentKey(ItemNumber);
     _BaseOrderLineElementView.Ascending(false);
end;


Example 2

  • Change key to existing field "Order No."

[EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrders_OnAfterSetCurrentKey''', true, true)]
procedure OnGetReceiveOrders_OnAfterSetCurrentKey(var _BaseOrderElementView: Record "MOB Ns BaseDataModel Element")
begin
     _BaseOrderElementView.SetCurrentKey(BackendID);
     _BaseOrderElementView.Ascending(true);
end;


Sorting on Custom fields ("OnAfterSetFrom"-events)

...


    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Pick", 'OnGetPickOrders_OnAfterSetFromAnyHeader''', true, true)]
    local procedure MySortByCustomTag_OnGetPickOrders_OnAfterSetFromAnyHeader(_RecRef: RecordRefvar _BaseOrderElement: Record "MOB Ns BaseDataModel Element")
    var
        DataTypeManagement: Codeunit "Data Type Management";
        NewFieldRef: FieldRef;
    begin
        if DataTypeManagement.FindFieldByName(_RecRef, NewFieldRef, 'Assigned User ID'then
            _BaseOrderElement.SetValue('AssignedUserID''Assigned to: ' + CopyStr(NewFieldRef.Value()1, NewFieldRef.Length()));

        _BaseOrderElement.Set_Sorting1(_BaseOrderElement.GetValue('AssignedUserID'));
    end;

Example 2:

Sort only Warehouse Picks by "Assigned User ID"

...


    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Pick", 'OnGetPickOrders_OnAfterSetFromWarehouseActivityHeader''', true, true)]
    local procedure My02GetPickOrders_OnAfterSetFromWarehouseActivityHeader(_WhseActHeader: Record "Warehouse Activity Header"; var _BaseOrderElement: Record "MOB Ns BaseDataModel Element")
    begin
        _BaseOrderElement.SetValue('AssignedUserID''Assigned to: ' + _WhseActHeader."Assigned User ID");
        _BaseOrderElement.Set_Sorting1(_BaseOrderElement.GetValue('AssignedUserID'));
    end;