Description
Excerpt |
---|
Examples of sorting Order list |
...
Change sorting key
- Use
Set_Sorting1()-
function.Filter by label (Content by label) showLabels false showSpace false cql label = "bc" and label = "orders" and label = "onaftersetfrom" and label = "integrationevent"
- 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 (Set_Sorting1..5) so you can sort up to four new custom fields.
...
title | See event parameters |
---|
...
_BaseOrderElement
Helper functions to identify and manipulate the Order-element
...
- Set a custom value
...
Get_Value
- Get any value already set on the element
Get_BackendID
- Get Order No.
Get_RecRefFromReferenceID
- Get RecordRef to the Order
Sorting multiple document sources using "Any-event"
If you work across locations you might also want to filter across all of them
For example, the sorting for Receive orders list is:
- Warehouse Receipts
- Purchase Orders
- Transfer Orders
- Sales Return Orders
All four document sources can be in the same list (with each internally ordered by document numbers)
If you filter across all document types, then use the "Any"-event, else use the document-specific event(s)
Sorting on Existing fields ("OnAfterSetCurrentKey"-events)
Example 1
- Change key to existing field "Item no."
- Change sorting direction to "Descending"
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Put Away", 'OnGetPutAwayOrderLinesSorting multiple document sources using "Any-event"
If you work across locations you might also want to filter across all of them
For example, the sorting for Receive orders list is:
- Warehouse Receipts
- Purchase Orders
- Transfer Orders
- Sales Return Orders
All four document sources can be in the same list (with each internally ordered by document numbers)
If you filter across all document types, then use the "Any"-event, else use the document-specific event(s)
Sorting on Existing fields ("OnAfterSetCurrentKey"-events)
Example 1
- Change key to existing field "Item no."
- Change sorting direction to "Descending"
[EventSubscriber(ObjectType::Codeunit, Codeunit::"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::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrders_OnAfterSetCurrentKey', '', true, true)]
procedure OnGetPutAwayOrderLines OnGetReceiveOrders_OnAfterSetCurrentKey(var _BaseOrderLineElementViewBaseOrderElementView: Record "MOB Ns BaseDataModel Element")
begin
_BaseOrderLineElementViewBaseOrderElementView.SetCurrentKey(ItemNumberBackendID);
_BaseOrderLineElementViewBaseOrderElementView.Ascending(falsetrue);
end;
Example 2
- Change key to existing field "Order No."
[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;
Sorting on Custom fields ("OnAfterSetFrom"-events)
Note. For this task: you must both:
...
...
Sorting on Custom fields ("OnAfterSetFrom"-events)
Note. For this task: you must both:
- Set the value
- Enable sorting on it
Expand | ||
---|---|---|
| ||
|
Example 1:
Sort all picks by "Assigned User ID"
...
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Pick", 'OnGetPickOrders_OnAfterSetFromAnyHeader', '', true, true)]
local procedure MySortByCustomTag_OnGetPickOrders_OnAfterSetFromAnyHeader(_RecRef: RecordRef; var _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::Codeunit, Codeunit::"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;