Introduction
This article describes how to add a new custom action to a "BurgerMenu" at existing pages.
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.
In this example, a reference to the source document line is needed by the Pick Robot. Therefore, a new configuration header must include the OrderBackendID and LineNumber. Addtional fields (ItemNumber, DisplayLine1 etc.) could be added to the configuration header as well, to help user identify the line being handled. However, for this example we included only the neccessary two fields.
local procedure AddHeaderConfiguration(var XMLResponseData: XmlNode); begin [.....] // >> SendToPickRobot CreateHeaderConfiguration(XMLResponseData, 'SendToPickRobotHeader'); // << SendToPickRobot [.....] end;
procedure CreateHeaderConfiguration(var XMLResponseData: XmlNode; "Key": Text[50]); var [.....] begin [.....] POST_SHIPMENT_HEADER_Txt: AddPostShipmentHeaderValues(XMLCDataSection); // >> SendToPickRobot 'SendToPickRobotHeader': AddSendToPickRobotHeaderValues(XMLCDataSection); // << SendToPickRobot [.....] end;
// >> 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: Associate configuration header with new page in application.cfg
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".
<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 to existing "BurgerMenu"
The new "Send To Robot" action is added to the existing PickLines-page in application.cfg – this will associate the action to the new page we created above. The entire page is shown below, but only this line is new:
<open id="SendToPickRobot" icon="" title="Send To Robot" />
<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."
As per our "Send To Robot"-page defnition the submit button will submit a DocumentType='PostAdhocRegistration', RegistrationType='SendToPickRobotRegistrationType' request.
We need to catch this RegistrationType and forward to our own new code in the backend;
procedure PostAdhocRegistration(); var [.....] begin [.....] MobWMSToolbox."CONST::Internal"(): begin Status := Internal(XMLRequestDoc, RegistrationTypeTracking); MOBToolbox.CreateSimpleResponse(XMLResultDoc, Status); end; // >> SendToPickRobot 'SendToPickRobotRegistrationType': begin Status := SendToPickRobot(XMLRequestDoc, RegistrationTypeTracking); MOBToolbox.CreateSimpleResponse(XMLResultDoc, Status); end; // << SendToPickRobot [.....] end;
This sample backend code will only mock a reply, but do nothing else. The OrderBackendID and LineNumber is parsed from the request, and a succes response is created. (the MObXmlMgt.XPathInnerText() function call from the example requires MOB4.38 or later).
// >> SendToPickRobot local procedure SendToPickRobot(XMLRequestDoc: XmlDocument; var ReturnRegistrationTypeTracking: Text[200]): Text[60]; var MobXmlMgt: Codeunit "MOB XML Management"; OrderBackendID: Code[23]; 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:
The mobile document queue shows the registration type tracking information we returned:
Associated Request:
Associated Response: