- Created by Johannes Sebastian Nielsen, last modified on Jun 28, 2022
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 68 Next »
Description
Examples of sorting Order Lines.
Flow of events
Sorting on Existing fields
Use OnAfterSetCurrentKey-events.
Change sorting key
- Use
.SetCurrentKey(field, [field2, ...])
-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:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Sorting on Custom fields
Use.OnAfterSetFrom-events.
Change sorting key
- Use
Set_Sorting1()-
function.
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
- 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 .
Example: Sort by existing field Item No.
- 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", 'OnGetReceiveOrderLines_OnAfterSetCurrentKey', '', true, true)]
procedure MyOnGetReceiveOrderLines_OnAfterSetCurrentKey(var _BaseOrderLineElementView: Record "MOB Ns BaseDataModel Element")
begin
_BaseOrderLineElementView.SetCurrentKey(ItemNumber);
_BaseOrderLineElementView.Ascending(false);
end;
Example: Sort by existing field Quantity
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Pick", 'OnGetPickOrderLines_OnAfterSetFromAnyLine', '', true, true)]
procedure My2OnGetPickOrderLines_OnAfterSetFromAnyLine(_RecRef: RecordRef; var _BaseOrderLineElement: Record "MOB Ns BaseDataModel Element")
begin
_BaseOrderLineElement.Set_Sorting1(_BaseOrderLineElement.Get_Quantity().PadLeft(10, '0'));
end;
Example: Sort by a custom field
- Sort lines by you own custom field
For this task you must use the OnAfterSetFrom event.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAfterSetFromAnyLine', '', true, true)]
procedure OnGetReceiveOrderLines_OnAfterSetFromAnyLine(_RecRef: RecordRef; var _BaseOrderLineElement: Record "MOB Ns BaseDataModel Element")
var
Item: Record Item;
begin
with _BaseOrderLineElement do begin
// New custom tag
Item.Get(Get_ItemNumber());
SetValue('SpecialEquipmentCode', Item."Special Equipment Code");
// Sort by custom tag
Set_Sorting1(GetValue('SpecialEquipmentCode'));
end;
end;
How it works behind the scenes
The "sorting" tags determines the sorting on mobile as part of Order Lines GetOrderLines Response.
- These examples affects the sorting value indirectly by affecting the looping of the record.
- The sorting value is automatically calculated as a result of of the looping order.
See also
-
Page:How-to: Sorting of Order Lines — Examples of sorting Order Lines.
-
Page:OnGetPickOrderLines_OnAfterSetFromAnyLine — Populate values on Order Lines displayed at the mobile device (derived from any of four associated line tables). Parameters includes a RecRef-instance for the line table.
-
Page:OnGetReceiveOrderLines_OnAfterSetFromAnyLine — Populate values in Order Lines displayed at the mobile device (derived from any of four associated line tables). Parameters includes a RecRef-instance for the line table.
Order Lines on the mobile device.
- No labels