Create a Lookup with Adhoc Registration

Description

Two pages that will:

  1. Show ("look up") a list of entries 
  2. Make registration regarding each entry on the list (An "Unplanned Item Registration")


Use case examples

  • You want to search for and display a list of outstanding "items" to "handle".
  • When you have handled each item, you want that item to disappear from the list and proceed to the next item.

or

  • You want to search for and display a list of Jobs.
  • Select one or more job and make registrations of Items or Hours etc. spent on that job.


How to use it

Defining the pages

Step 1: Defining the Lookup

Below is sample code for a Lookup called "MyLookup"


Add to application.cfg
<page id="MyLookup" type="Lookup" icon="mainmenuscaninfo">
  <title defaultValue="Titel"/>
  <lookupConfiguration type="MyLookup">
    <header configurationKey="MyLookup" automaticAcceptOnOpen="true" />
    <onResultSelected enabled="true" refreshOnSuccess="true" navigateTo="MyItemReg"/>
    <list listId="Lookup" />
  </lookupConfiguration>
  <actions>
    <open id="MyItemReg" icon="mainmenusettings" title="My UnplannedItemRegistration">
      <transfer property="LookupSelectedResult" to="UnplannedItemRegistrationInputValue"></transfer>
      <returnTransfer property="UnplannedItemRegistrationCompleted" to="RefreshOnResume"/>
    </open>
  </actions>
</page>


Step 2: Unplanned Item Registration 

Below is sample code for an Unplanned Item Registration called "MyItemReg"


Add to application.cfg
<page id="MyItemReg" type="UnplannedItemRegistration" icon="mainmenuscaninfo">
  <title defaultValue="Titel"/>
  <unplannedItemRegistrationConfiguration type="MyItemReg" includeInputDataRowInSubmitRequest="true" useRegistrationCollector="true">
    <header configurationKey="MyItemReg" clearAfterPost="true" automaticAcceptOnOpen="true" automaticAcceptAfterLastScan="true"/>
    <onSuccessfulPost close="true" />
  </unplannedItemRegistrationConfiguration>
</page>

Please note:

For simplicity the Page id, Registration key and Header Key are all name the same.

  • Page id uniquely identifies the page in the config file

  • Registration key is how the back-end will identify the Unplanned Item Registration (including the Collector Steps)

  • Header key  is how the back-end will identify the Input fields shown on the top of the page. 


Step 3: Add the main menu items

Add to application.cfg
<!-- PAGES -->
<pages>
  <page id="MainMenu" type="Menu" icon="icon">
    <title defaultValue="Mobile WMS" />
    <menuConfiguration>
      <menuItems>          
		...
        <menuItem id="MyLookup" displayName="MyLookup" icon="mainmenumove-unplanned" alwaysEnabled="true"/>
        <menuItem id="MyItemReg" displayName="MyItemReg" icon="mainmenushipping" alwaysEnabled="true"/>
        ...

Handling the back-end

Step 4: Defining a shared Header for the Pages

This will define the field(s) displayed on the top of the Lookup aka the search criteria.

But it will also enable the MyItemReg page to "Receive" this information.


So the header will be shared between the two pages.


For simplicity we will only have a field called "ID".



This is defined in Codeunit "MOB WMS Reference Data"


CreateConfig(XMLResponseData,'MyLookup');
CreateConfig(XMLResponseData,'MyItemReg');



'MyLookup','MyItemReg': MyLookupAndMyItemReg(XMLCDataSection);


MyLookupAndMyItemReg(VAR XmlCDataSection : DotNet "System.Xml.XmlCDataSection")
// Used for Custom05UnplannedItemReg

AddConfHeaderTextValue(XmlCDataSection,
                       1,                 //id
                       'ID',              //name
                       'Enter ID:',       //label
                       100,               //label width
                       TRUE,              //clear on clear
                       TRUE,              //accept barcode
                       20,                //length
                       TRUE,              //optional
                       '',                //search type
                       '',                //eanAi
                       FALSE);            //locked

Step 5: Handling the Request for Lookup 

This is the code that will return the list of results and entries that you require.

We will have some dummy Line data.


This is defined in Codeunit "MOB WMS Lookup"

LOCAL MyLookup(XMLRequestDoc : DotNet "System.Xml.XmlDocument")

// The parameters are located in the <requestData> element
MobXMLMgt.GetDocRootNode(XMLRequestDoc, XMLRequestNode);
MobXMLMgt.FindNode(XMLRequestNode, 'requestData', XMLRequestDataNode);

// Read the header field value of field "ID" 
MobXMLMgt.FindNode(XMLRequestDataNode, 'ID', XMLParameterNode);   // <---- Use the read values for your further logic...

// Initialize the response XML
MobBaseToolbox.InitializeResponseDocWithNS(XMLResultDoc, XMLResponseData, 'http://schemas.taskletfactory.com/MobileWMS/WarehouseInquiryDataModel');

// Create response values

REPEAT // <----- Create logic to generate lookup result
   MobXMLMgt.AddElement(XMLResponseData, 'LookupResponse', '', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLLookupResponse);

  // Add the data elements to the <LookupResponse> element
  MobXMLMgt.AddElement(XMLLookupResponse, 'Location', 'Location xxx', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'ID', 'LinkLookupToReg', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'DisplayLine1', 'Line 1', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'DisplayLine2', 'Line 2', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'DisplayLine3', 'Line 3', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'DisplayLine4', 'Line 4', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'DisplayLine5', 'Line 5', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'ExtraInfo1', '', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'ExtraInfo2', '', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);
  MobXMLMgt.AddElement(XMLLookupResponse, 'ExtraInfo3', '', MobXMLMgt.GetNodeNSURI(XMLResponseData), XMLCreatedNode);

  Int += 1;
UNTIL Int = 3;


Step 6: Defining the "Steps" to collect 

This is the code that will return the list of results and entries that you require.


This is defined in Codeunit "MOB WMS Adhoc Regstr."


'MyItemReg':
    BEGIN
      MyItemReg(XMLRequestDoc);
    END;



LOCAL MyItemReg(XMLRequestDoc : DotNet "System.Xml.XmlDocument")
// Extract any parameters from the XML
// The parameters are located in the <requestData> element
// The Unplanned Move feature expects 2 header values
// Location and Item
MobXMLMgt.GetDocRootNode(XMLRequestDoc, XMLRequestNode);
MobXMLMgt.FindNode(XMLRequestNode,MobWMSToolbox."CONST::requestData",XMLRequestDataNode);

// -- Now find the "ID"-attribute
MobXMLMgt.FindNode(XMLRequestDataNode,'ID',XMLParameterNode);

// Initialize the response xml
MobBaseToolbox.InitializeRespDocWithoutNS(XMLResultDoc,XMLResponseData);

// Add the <registrationCollectorConfiguration> element
MobXMLMgt.AddElement(XMLResponseData,'registrationCollectorConfiguration','',
                     MobXMLMgt.GetDocNSURI(XMLResultDoc),
                     XMLRegCollectorConfiguration);

// Add the <steps> element to the <registrationCollectorConfiguration>
MobXMLMgt.AddElement(XMLRegCollectorConfiguration,'steps','',MobXMLMgt.GetDocNSURI(XMLResultDoc),XMLSteps);

// Add the steps
MobConfTools.RC_Std_Parms(1,
                          'SomeText',
                          'Collecting some text',
                          '',
                          'Please enter some text');

MobConfTools.RC_Text_XmlNode(XMLSteps,
                             '',
                             20);



This will produce one collector step.

Asking for a text value.


Step 7: Handling the "posting" of Unplanned Item Registration

This code read the collected data and posts it.

If this code makes changes to the data the Lookup uses, you will see the result of the posting when the returning to the Lookup.


This is defined in Codeunit "MOB WMS Adhoc Regstr."


'MyItemReg':
  BEGIN
    Status := PostMyItemReg(XMLRequestDoc);
    MobBaseToolbox.CreateSimpleResponse(XMLResultDoc,Status);
  END;

Create function "PostMyItemReg" by copying an existing posting function.

  • Modify the new function to read the "ID" and "SomeText" values.





The lookup


The Unplanned Item Registration