Introduction
This article describes how to add a new custom action to a "BurgerMenu" at existing pagesthe context or action menus.
In this example a menu item is added to the Pick order lines list, to send instructions to a Pick Robot to fetch an item from warehouse and move to the physical pick area. While no instructions are actually issued to a Pick Robot in this example, it will show how to create the neccessary pages and how to trigger custom code in the backend.
...
... the "Send to Robot"-option will open a new "Send To Robot"-page, including a "SUBMIT" that will trigger our mocked code in the backend.
Overview
The steps to create a new menu action are (discussed in details below):
- New Configuration Header for "Send To Robot"-page
- Associate configuration header with new page in application.cfg
- Add action to existing "BurgerMenu"
- Handle new RegistrationType in codeunit "MOB WMS Adhoc Registr.
- Testing the solution
Example
Step 1: New Configuration Header for "Send To Robot"-page
To be able to submit a request to the backend, a page must exist including visible fields that holds the information needed by the backend. The SUBMIT request will include the visible fields and its values.
...
Code Block | ||
---|---|---|
| ||
local procedure AddHeaderConfigurationAddConfiguration(var XMLResponseData: XmlNode); begin [.....] CreateConfig(XMLResponseData,REGISTER_IMAGE_HEADER); // >> SendToPickRobot CreateHeaderConfiguration(XMLResponseData, CreateConfig(XMLResponseData,CREATE_ASSEMBLY_ORDER_HEADER); CreateConfig(XMLResponseData,ADJUST_QTY_TO_ASSEMBLE_HEADER); CreateConfig(XMLResponseData,ATTACHMENTS_HEADER); CreateConfig(XMLResponseData,'SendToPickRobotHeader'); // << SendToPickRobot [.....] //<---- end; |
Code Block | ||
---|---|---|
| ||
procedure CreateHeaderConfiguration(var XMLResponseData: XmlNode; "Key": Text[50]); varbegin [.....] begin [.....] POST_SHIPMENT_HEADER_Txt ADJUST_QTY_TO_ASSEMBLE_HEADER: BEGIN AddPostShipmentHeaderValuesAddAdjustQtyToAssembleHeaderValues(XMLCDataSection); END; // >> SendToPickRobot 'SendToPickRobotHeader' ATTACHMENTS_HEADER: BEGIN AddSendToPickRobotHeaderValuesAddAttachmentsHeaderValues(XMLCDataSection); END; 'SendToPickRobotHeader': //<---- << SendToPickRobot AddSendToPickRobotHeaderValues(XMLCDataSection); [.....]//<---- end; |
Code Block | ||
---|---|---|
| ||
// >> SendToPickRobot local procedure AddSendToPickRobotHeaderValues(var XmlCDataSection: XmlCdata); begin // Add the header lines AddConfHeaderTextValue(XmlCDataSection, 1, //id 'OrderBackendID', //name MobWmsLanguage.GetMessage('BATCH_NAME') + ':', //label 100, //label width false, //clear on clear false, //accept barcode 20, //length false, //optional '', //search type '', //eanAi true); //locked // Line Number AddConfHeaderTextValue(XmlCDataSection, 2, //id 'LineNumber', //name MobWmsLanguage.GetMessage('LINENUMBER') + ':', //label 100, //label width false, //clear on clear false, //accept barcode 20, //length false, //optional '', //search type '', //eanAi true); //locked end; // << SendToPickRobot |
The code above will add a new entry to Reference Data, identified by new Key "SendToPickRobotHeader".
Step 2:
...
Add new page
...
Next, our new configuration header "SendToPickRobotHeader" needs to be associated with a new page in application.cfg. The
type="UnplannedItemRegistration" (qua existing Document Type setup) will trigger the handler codeunit "MOB WMS Adhoc Registr.". The SUBMIT-button for the page is associated to new RegistrationType type="SendToPickRobotRegistrationType".Modify the Mobile Configuration Files
Code Block | ||
---|---|---|
| ||
<page id="SendToPickRobot" type="UnplannedItemRegistration" icon=""> <title defaultValue="Send To Robot"/> <unplannedItemRegistrationConfiguration type="SendToPickRobotRegistrationType" useRegistrationCollector="false"> <header configurationKey="SendToPickRobotHeader" automaticAcceptAfterLastScan="true"/> </unplannedItemRegistrationConfiguration> </page> |
Step 3: Add action
...
The new "Send To Robot" action is added to the existing PickLines-page in application.cfg – this
This will associate the action to the new page we created above. The entire page is shown below, but only this line is new:
Add this line to "PickLines"-pagen.
<open id="SendToPickRobot" icon="" title="Send To Robot" />
Modify the Mobile Configuration Files
Code Block | ||
---|---|---|
| ||
<page id="PickLines" type="OrderLines" icon="mainmenupick"> <title defaultValue="@{PagePickOrderLinesTitle}"/> <orderLinesConfiguration> <service id="Pick"/> <list listId="OrderLinesWithImages"/> <viewRegistrations title="@{OrderLinesRegistrationMenuItem}" navigateTo="ViewRegistrations" enabled="true"/> <deleteOrderRegistrations title="@{OrderLinesDeleteAllOrderRegistrationsMenuItem}" enabled="true"/> <totePicking allowManualSelection="true"> <currentTote show="true" useLabelPrefix="false"/> </totePicking> <scanToSelectBehaviour gs1SearchTerm="Item" behaviour="Auto"/> </orderLinesConfiguration> <actions> <showImage id="1" enabled="true" imageProperty="ItemImage" title="@{MenuItemShowImageTitle}"/> <open id="SendToPickRobot" icon="" title="Send To Robot" /> </actions> </page> |
Step 4: Handle new RegistrationType in codeunit "MOB WMS Adhoc Registr."
The type="UnplannedItemRegistration" (qua existing Document Type setup) will trigger the handler codeunit "MOB WMS Adhoc Registr.".
The SUBMIT-button for the page is associated to new RegistrationType type="SendToPickRobotRegistrationType".
As per our "Send To Robot"-page defnition the submit button will submit a DocumentType='PostAdhocRegistration', RegistrationType='SendToPickRobotRegistrationType' request.
...
Code Block | ||
---|---|---|
| ||
// >> SendToPickRobot local procedure SendToPickRobot(XMLRequestDoc: XmlDocument; var ReturnRegistrationTypeTracking: Text[200]): Text[60]; var MobXmlMgt: Codeunit "MOB XML Management"; OrderBackendID: Code[2023]; LineNumber: Integer; begin // Disable the locktimeout to prevent timeout messages on the mobile device LOCKTIMEOUT(false); MobDocQueue.LoadXMLRequestDoc(XMLRequestDoc); OrderBackendID := MobXmlMgt.XPathInnerText(XMLRequestDoc, '//req:OrderBackendID'); Evaluate(LineNumber, MobXmlMgt.XPathInnerText(XMLRequestDoc, '//req:LineNumber')); // Mock something that can be recognized at the mobile device for this example ReturnRegistrationTypeTracking := StrSubstNo('MOCK Fetch OrderBackendID %1, LineNumber %2', OrderBackendID, LineNumber); exit('MOCK PickRobot instructions was issued'); end; // << SendToPickRobot |
Step 5: Testing the solution
Submitting from the "Send To Robot" page should now display the message we returned from our custom "SendToPickRobot()"-method:
...