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 38 Next »

Description

Examples of sorting Order list

 

Flow of events




Sorting on Existing fields

Use OnAfterSetCurrentKey-events.



Sorting on Custom fields

Use.OnAfterSetFrom-events.



Helper Functions

The event parameter "_BaseOrderLineElementView" includes five sorting functions you can use to sort on up to four new custom fields.


Sorting on multiple document sources

All except "Ship" have multiple document sources.

I.e. the default sorting for Receive orders list at the mobile device is:

  • First, Warehouse Receipts
  • Then Purchase Orders
  • Then Transfer Orders
  • Then Sales Return Orders

... so essentially "grouping" orders by the four document sources that can all be in the same list (with each "group" being internally ordered by document numbers).


When working with custom sorting you must consider: Should the filter be applied across all document types?

  • If yes, use the "Any"-event
  • If no, use the specific event(s)


Example: Existing fields

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

For this task, you must use the OnAfterSetCurrentKey event.


[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;




Example: Custom fields

Sort lines by your own custom field

For this task:

  • You must use the "OnAfterSetFrom"-event
  • both set the value and enable sorting on it


[EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAfterSetFromAnyLine''', true, true)]
procedure OnGetReceiveOrderLines_OnAfterSetFromAnyLine(_RecRef: RecordRefvar _BaseOrderLineElement: Record "MOB Ns BaseDataModel Element")
var
     Item: Record Item;
begin
     with _LineElement do begin
          // New custom tag
          Item.Get(Get_ItemNumber());
          SetValue('SpecialEquimentCode', Item."Special Equipment Code");

          // Sort by custom tag
          Set_Sorting1(GetValue('SpecialEquimentCode'));
     end;
end


  • No labels