Application
This is applicable for Microsoft Dynamics 365 Supply Chain Management, a.k.a. Finance and Operations.
The solution presented here uses the extension capabilities in 365, but can easily be converted to work in AX2012 using the overlayering capability of that system.
Problem
There is a need to prompt the user for additional information, when they are about to post an order from the device, and have the posting reflect this.
In this example the user must be prompted whether or not to consume items on a receive order, if it has reference to a sales order.
Solution
This can be achieved by extending the Class MobReceiveOrderTypePurchOrder. This contains the logic for handling purchase orders
Handling of Purchase Orders are in what is categorized as a planned flow. In a planned flow, the communication between mobile device and backend consists of 3 requests. 1 request for all headers, i.e. Purchase Orders, 1 request for the lines of a chosen Order header. And a request to post.
When the user requests the lines for a given header, all the lines are sent to the device. At the same time, if needed, the information the user must be prompted for, when posting the lines are sent out. This allows the user to make all the registrations offline, and fill out the info needed when posting, without making an extra call to the backend.
The fields to prompt the user for, when posting, is handled in a method called getPostPromptCollectors(...)
To add a new field to the prompting flow we can add the following;
[ExtensionOf(classStr(MobReceiveOrderTypePurchOrder))] final class MobReceiveOrderTypePurchOrderExample_extension { public Map getPostPromptCollectors(str _backendID) { Map ret = next getPostPromptCollectors(_backendID); PurchId purchId = conPeek(MobHelper::strSplit(_backendID,'/').pack(),6); PurchLine purchLine; SalesTable salesTable; select firstonly salesTable where salesTable.SalesType == SalesType::ItemReq join purchLine where purchLine.inventRefId == salesTable.SalesId && purchLine.itemRefType == InventRefType::Sales && purchLine.PurchId == purchId; if (salesTable) { ret.insert('consumeItems',MobRegistrationCollectorList::ListStepMap(true,100,'consumeItems',"Consume items on Order?","Consume items on Order?","Consume items on Order?",'Yes;No')); } return ret; }
In line 16, a new Registration Collector is added. Registration Collectors is the term used in Mobile WMS, for when a field in a flow is shown to the user.
In this case, the chosen type is a list Registration Collector, which is equivalent to a Combo Box control.
You can read more about the different types of steps here. In D365 All Registration Collectors are Prefixed with MobRegistrationCollector[Type].
When compiling, and going into a purchase order with item Requirements the posting prompt looks like this:
What is missing now, is this being handled in the posting process.
To do this, an extension must also be made to the postRequest() method on the MobReceiveOrderTypePurchOrder class:
public str postRequest(MobRequestOrdersElement _orderElement) { boolean consumeItems = _orderElement.getFieldValue('consumeItems') == 'Yes'; str retStr = next postRequest(_orderElement); //Add logic to consume items here return retStr; } }
That should be sufficient changes to do the required customization.
The _orderElement is of the type MobRequestOrdersElement, and adding a parmMethod called parmConsumeItems on this class through an extension, will make the value available on this parm method. No need to do more, the system will adapt to the new parmMethod.
This pattern is the same, when customizing other planned flows
See also