Blog |

Advanced WHS Mobile Device Development: [Part 3] – The Sales Line-List Functionality

Wednesday, July 15, 2020
Reading time: 3 minutes

Welcome to the third part of our WHS mobile device development series where we walk through a three-step process to implement process guide framework in Dynamics 365 Finance & Supply Chain Management.

Throughout this blog, you will learn how the process guide framework can be utilized to create a list window in Dynamics 365 Finance & Supply Chain Management mobile device.

Dynamics 365 WHS Mobile Device Development: Step 2 - Sales Line List

This step is the most complicated of all the steps in this blog series, however, it has similarities to the old standard that we have discussed in the previous blog posts. The logic is the same but wrapped in a different syntax. List functionality has a similar structure to the previous versions. Primarily, it requires three methods:

  1. buildHeader()
  2. buildTableContents()
  3. buildPagingControls()

In the buildHeader() method you can add the title of the step, filtering buttons and buttons for additional tile information. As an example, we will be showing sales line quantity and sales price as additional fields.

//Fort title, filtering and additional field display

    private void buildHeader(ProcessGuidePage _page)
    {
        _page.addLabel(SOLINELIST, SOLINELIST, extendedTypeNum(WHSRFUndefinedDataType));
        //Add a button for every additional field
        _page.addButton(step.createAction(#ActionOk), falseProcessGuideDataTypeNames::Qty);
        _page.addButton(step.createAction(#ActionOk), falseProcessGuideDataTypeNames::Field);
    }

The buildTableContents() method is responsible for populating the list with values. Usually, a query is used to iterate through records that match your requirements. In this scenario, the primary field is Item ID + sales line number but it can be whatever you like it to be. A code that adds sales line information is the following:

    private void addSalesLineTolist(ProcessGuidePage _page, SalesLine _salesLine)
    {
        str id    = _salesLine.ItemId + ‘, ‘ + int642Str(_salesLine.LineNum);
        str qty   = num2Str(_salesLine.SalesQty, 02DecimalSeparator::Dot, ThousandSeparator::Space);
        str price = num2Str(_salesLine.SalesPrice, 02DecimalSeparator::Dot, ThousandSeparator::Space);
        //First add list id as a button
        _page.ERAAddMultiActionButton(step.createAction(#ActionSelect), extendedTypeNum(ItemId), id);
        //You can add additional fields or display methods to the list button
        _page.addLabel(qty, qty, extendedTypeNum(SalesQty));
        _page.addLabel(price, price, extendedTypeNum(SalesPrice));
    }

We had to create a new ERAAddMultiActionButton() method to the ProcessGuidePage class since the original method was suited for just one particular process. This function is necessary to display records as a list view in the mobile device. This method looks like the following:

    public void ERAAddMultiActionButton(ProcessGuideAction _action,
                                     ExtendedTypeId        _inputType,
                                     str                   _label = ”,
                                     boolean               _isDefaultAction = false)
    {
        ProcessGuidePageMultiActionButton button = ProcessGuidePageMultiActionButton::newFromParameters(_action, _inputType, _label, _isDefaultAction);
        button.parmButtonData(_label);
        this.addControl(button);
    }

If you need to display additional information in the tile you have to add those fields using the _page.addLabel() method (see the example above).

Finally, we use the buildPagingControls() method to add list view-related buttons to the user interface.

    //Add buttons
    private void buildPagingControls(ProcessGuidePage _page)
    {
        _page.addButton(step.createAction(#RFPrev), false, “@SYS101819“);
        _page.addLabel(”, strFmt(“@WAX:WorkListPageControls“,
                                pageManager.getPageStart(), pageManager.getPageEnd(), pageManager.parmTotalRecords()), extendedTypeNum(WHSRFUndefinedDataType));
        _page.addButton(step.createAction(#RFNext), false, “@SYS307055“);
        _page.addButton(step.createAction(#ActionBackProcess));
    }

For this step, ERASalesProcessGuidePromptSalesLineListStep class will save the selected tile information to the WhsrfPassthrough object and check that it is not empty:

public static const str SALESLINEC = ‘salesLine‘;
    protected boolean isComplete()
    {
        #ProcessGuideActionNames
        WhsrfPassthrough pass = controller.parmSessionState().parmPass();
        if (!pass.exists(SALESLINEC))
        {
            return false;
        }
        return true;
    }
    public void doExecute()
    {
        str salesLine = controller.parmClickedData();
        if (salesLine)
        {
            WhsrfPassthrough pass = controller.parmSessionState().parmPass();
            pass.insert(SALESLINEC, salesLine);
        }
        super();
    }

If there’s a need, you can process the selected data in the doExecute() method and then continue with your process.

The result of this step should look similar to figure below:

Figure 1. Step 2: Sales order line list

We hope that you have found these insights helpful and that they will help in improving your WHS mobile device development in Dynamics 365 Finance and Supply Chain Management. Don’t hesitate to contact our team at service@companial.com if you have any questions or require any further information!

In case you missed Part 1 or Part 2 of the blog series, be sure to check them out to find out more about the first steps in the process guide framework.

Part 4 of this series on the Dynamics 365 Finance & Supply Chain Management WHS mobile development process is available here.

Edgaras Radvilas

Mehr über Finance and Supply Chain Management

Anaxco

Navigating the Dynamics 365 Transition: Anaxco's Journey to Operational Excellence with Companial's Support

Mehr lesen