Description
Examples of sorting Order list.
Sorting on Existing fields
Use OnAfterSetCurrentKey-events.
Change sorting key
- Use
.SetCurrentKey(field)
-function with any of the existing fields from the Line table (Record parameter on this event).
- Use
Change sorting direction
- Use
.Ascending(true/false)
-function.
- Use
- Use these events:
-
Sorting on Custom fields
Use.OnAfterSetFrom-events.
Change sorting key
- Use
Set_Sorting1()-
function.
-
- Use
Change sorting direction
- This is done in two steps:
- Use OnAfterSetFrom[ and the
Set_Sorting1()
-function. - Use OnAfterSetCurrentKey and the
.Ascending()
-function.
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 will need to consider whether orders should still be "grouped" or can now be mixed across the four document sources.
Example
Example: Existing fields
- Change key to existing field "Item no."
- Change sorting direction to "Descending"
For this task you can use an OnAfterSetCurrentKey event.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"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;
TODO – Keywords:
OnAfterSetCurrentKey:
- On for fields in table (explain table)
- Ascending or descending sort
- Requires table extension to sort on new custom tags, otherwise use Set-functions.
- Currently do not support retaining "grouping" by document sources
Using Set-functions:
- For any fields, including new custom fields
- Can retain "grouping" by document source if desired
- Cannot set ascending/descending sorting. Must use OnAfterSetCurrentKey for this,