How to create a new header for Planned functions, in order to filter which documents to include (or exclude).
This articles describes creating a new custom header, this is only needed when creating entirely new functionality.
Perhaps you looking for filtering standard headers?
- How-to: Filter Orders
- How-to: Filter Orders - Complex
Step 1 - Define Header and Filters
Use the OnGetReferenceData_OnAddHeaderConfigurations to create you new header.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddHeaderConfigurations', '', true, true)]
local procedure OnGetReferenceData_OnAddHeaderConfigurations(var _HeaderFields: Record "MOB HeaderField Element")
begin
with _HeaderFields do begin
InitConfigurationKey('MyReceiptFilters'); // New Header name to use instead of "ReceiveOrderFilters"
// Add standard location filter - this is already handled in standard Receive
Create_ListField_Location(1);
// Add our new custom filter - this is declared fully. It is a Text field.
Create_TextField(2, 'DocumentNoFilter');
Set_label('Doc. filter label:');
Set_clearOnClear(true);
Set_acceptBarcode(true);
Set_length(20);
Set_optional(true);
end;
end;
- Note how helper-functions like Add_Location and Add_TextValue are used
- There are many more to choose from
We have created a new header for Receive.
Currently you cannot overrule an existing header, so you must modify the standard Receive header in Mobile configuration like so:
<page id="Receive" type="OrderList" icon="mainmenureceive">
<title defaultValue="@{PageReceiveOrderListTitle}" />
<orderListConfiguration automaticOrderSelectionAfterFilter="true">
<service id="Receive" />
<!--CUSTOM-->
<!--<filter configurationKey="ReceiveOrderFilters" />-->
<filter configurationKey="MyReceiptFilters" />
<!--CUSTOM-->
<list listId="Orders" />
<onOrderSelected navigateTo="ReceiveLines" />
<unlockOrder title="@{ReleaseOrderMenuItem}"/>
</orderListConfiguration>
</page>
Select all the events for the Planned function you are working on (We used "Receive" in this guide)
Filter by label
There are no items with the selected labels at this time.
A change in filter "PO Number" must affect both:
- Receiving on "Warehouse Receipts" (based on Purchase orders)
- Receiving directly on "Purchase Orders"
Make your code callable from both events:
- Create a new procedure and call it from both events
- Line filters affect which Order Headers are relevant.
- If no Order Lines exists for a Header. The header is not included in the response.
Step 5 - Handle each document event
There are four OnSetFilter-events for Receive.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrders_OnSetFilterWarehouseReceipt', '', true, true)]
procedure OnGetReceiveOrders_OnSetFilterWarehouseReceipt(_HeaderFilter: Record "MOB NS Request Element"; var _WhseReceiptHeader: Record "Warehouse Receipt Header"; var _WhseReceiptLine: Record "Warehouse Receipt Line"; var _IsHandled: Boolean)
begin
// [Scenario] Handle/Apply filter to Warehouse Receipts
if _HeaderFilter.Name = 'DocumentNoFilter' then begin
if _HeaderFilter."Value" <> '' then
_WhseReceiptHeader.SetRange("No.", _HeaderFilter."Value");
_IsHandled := true;
end;
end;