Description
Excerpt |
---|
Examples of sorting Order list. |
Flow of events
Sorting on Existing fields
...
Change sorting key
- Use
.SetCurrentKey(field)
-function with any of the existing fields from the Header table (Record parameter on this event).
- Use
Change sorting direction
- Use
.Ascending(true/false)
-function.
- Use
- Use these events:
Filter by label (Content by label) showLabels false showSpace false cql label = "bc" and label = "orderlinesonaftersetcurrentkey" and label = "onaftersetcurrentkeyintegrationevent" and label = "integrationeventorders"
Sorting on Custom fields
...
Change sorting key
- Use
Set_Sorting1()-
function.Filter by label (Content by label) showLabels false showSpace false cql label = "bc" and label = "orderlinesorders" 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.
...
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.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::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;
Example: Custom fields
Sort lines by
...
your own custom field
For this task you :
- You must use the
...
- "OnAfterSetFrom"-event
- both set the value and enable sorting on it
[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 _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;