Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Description

The user wants to create two pages that can:

  1. Display a list of entries using a Lookup Function
  2. Make registrations regarding the lookup entry using an Unplanned Function

Selecting a lookup entry will navigate to the unplanned function.

Use cases

  • 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 enable it

To achieve this, changes in both the application.cfg and the backend are needed:

Step 1 - Changes in the application.cfg

In the application.cfg, we need to define the pages needed.


  • Step 1.1 Defining the Lookup page 
<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 1.2 Define the Unplanned page
<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>


  • Step 1.3 Add the main menu items
<!-- 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"/>
...

Read more about the Page Mobile configuration in the application.cfg here

Step 2 - Handling the back-end

After having modified the application.cfg, the next set of steps are about handling the back-end.


Step 2.1 Create header fields for both the lookup and the unplanned pages. 

Use OnGetReferenceData_OnAddHeaderConfigurations - The value that the user inputs will transfer to the Unplanned page, this is because both pages share the same Headerfield name, "ID"


    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAddHeaderConfigurations', '', true, true)]
    local procedure My01OnGetReferenceData_OnAddHeaderConfigurations(var _HeaderFields: Record "MOB HeaderField Element")
    begin
        // MyItemReg
        _HeaderFields.InitConfigurationKey('MyItemReg');
        _HeaderFields.Create_TextField(1, 'ID', 'Enter ID: ');
        _HeaderFields.Set_optional(true);

        // MyLookup
        _HeaderFields.InitConfigurationKey('MyLookup');
        _HeaderFields.Create_TextField(1, 'ID', 'Enter ID: ');
        _HeaderFields.Set_optional(true);
    end;


  • Step 2.2 Create a new Response Element  for the Lookup 

Use OnLookupOnCustomLookupType - For this example, three lines will be created and the value of the header field that the user input will be shown in the first line, as DisplayLine1


    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Lookup", 'OnLookupOnCustomLookupType', '', true, true)]
    local procedure OnLookupOnCustomLookupType(_MessageId: Guid; _LookupType: Text; var _RequestValues: Record "MOB NS Request Element"; var _LookupResponseElement: Record "MOB NS WhseInquery Element"; var _RegistrationTypeTracking: Text; var _IsHandled: Boolean)
    var
        Counter: Integer;
    begin
        if _LookupType <> 'MyLookup' then
            exit;

        // Create new Response Element
        for Counter := 1 to 3 do begin
            _LookupResponseElement.Create();
            // Getting a value from the headerfields and showing it in Displayline1
            _LookupResponseElement.SetValue('ID', _RequestValues.GetValue('ID'));
            _LookupResponseElement.Set_DisplayLine1(_LookupResponseElement.GetValue('ID'));
            _LookupResponseElement.Set_DisplayLine2(Format(Counter));
            _LookupResponseElement.Set_DisplayLine3('Line 3');
            _LookupResponseElement.Set_DisplayLine4('Line 4');

            _IsHandled := true;
        end;
    end;
  • Step 2.3 Create the steps for the Unplanned page

Use  OnGetRegistrationConfiguration_OnAddSteps For this example, only two steps will be created, a TextStep and a DecimalStep - You can read more about steps here.


   [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnGetRegistrationConfiguration_OnAddSteps', '', true, true)]
    local procedure MyOnGetRegistrationConfiguration_OnAddSteps(_RegistrationType: Text; var _HeaderFieldValues: Record "MOB NS Request Element"; var _Steps: Record "MOB Steps Element"; var _RegistrationTypeTracking: Text)
    begin
        if _RegistrationType = 'MyItemReg' then begin

            // STEP: Text step
            _Steps.Create_TextStep(1, 'SomeText', 'Collecting some text');
            // STEP: Decimal step
            _Steps.Create_DecimalStep(2, 'DecimalStep', 'Enter a number');
        end;
    end;
  • Step 2.4 Handle the posting of the Unplanned registration

Use OnPostAdhocRegistrationOnCustomRegistrationType - In this step, the data is  collected and posted. This can be further inspected in the Mobile Document queue list. You can read more about this here.


   [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType', '', true, true)]
    local procedure MyOnPostAdhocRegistrationOnCustomRegistrationType(_MessageId: Guid; _RegistrationType: Text; var _RequestValues: Record "MOB NS Request Element"; var _CurrentRegistrations: Record "MOB WMS Registration"; var _SuccessMessage: Text; var _RegistrationTypeTracking: Text; var _IsHandled: Boolean)
    var
        HeaderValue: Text;
        DecimalValue: Decimal;
        TextValue: Text;
    begin
        if _RegistrationType = 'MyItemReg' then begin
            if _IsHandled then
                exit;

            DecimalValue := _RequestValues.GetValueAsDecimal('DecimalStep');
            TextValue := _RequestValues.GetValue('SomeText');
            HeaderValue := _RequestValues.GetValue('ID');
            _SuccessMessage := StrSubstNo('Value from the Decimal step is: %1, value from the Text step is: %2 and value from the Headerfield is: %3', DecimalValue, TextValue, HeaderValue);
            _RegistrationTypeTracking := StrSubstNo('%1 - %2 - %3', DecimalValue, TextValue, HeaderValue);
            _IsHandled := true;
        end;
    end;

How does it look on the device

Step 2.2: Lookup page - the ID entered by the user is shown as the first line.

Step 2.3: Unplanned page - Steps shown to collect text and integer values.


Step 2.4: Mobile Document Queue List - Inspecting the Request.xml and Response.xml for PostAdhocRegistration

See also 



  • No labels