Sunday, June 2, 2019

List Page Form with multiselect in Dynamics Ax

In this example we want to create a Form using the List Page template and allow multi select to trigger a process on multiple records.

Create a table

image

Create a query

image

in this example we keep things simple and just set the Fields property as dynamic to include all fields

Create a class that extends ListPageInteraction

class FCH_ListPageWithMultiselectClass extends ListPageInteraction
{
}

the class in its basic can be as simple as that.

I suggest you always create a new class that extends ListPageInteraction so that you can eventually add your logic.

to see some examples you can look at this form:
\Forms\CustTableListPage which extends: \Classes\CustTableListPageInteraction

also here: http://sujanadynamics.blogspot.com/2013/10/list-page-interaction-class.html

Create the list page form

  1. In the AOT, right-click the Forms node, click New Form from template, and then click ListPage
  2. Click the InteractionClass property, expand the drop down list, and then click ListPageWithMultiselectClass (your class that extends ListPageInteraction).
  3. Specify the query to use with the list page, click the Data Sourcesnode for the form. then set its value to the query you created above
  4. In the Design node, right-click the grid, and then click Properties. In the properties window, click the DataSource property and set your datasource.
  5. Drag the fields from the datasource to the Grid.

see more on: https://docs.microsoft.com/en-us/dynamicsax-2012/developer/walkthrough-creating-a-list-page-and-adding-an-action-pane

Create a class to process records

class FCH_ListPageWithMultiselectProcess
{
    Args args;
}
public Args parmArgs(Args _args = args)
{
    args = _args;

    return args;
}
public static void main(Args _args)
{
    FCH_ListPageWithMultiselectProcess cl = new FCH_ListPageWithMultiselectProcess();
    cl.parmArgs(_args);
    cl.process();
}
private void process()
{
    MultiSelectionHelper selection = MultiSelectionHelper::createFromCaller(args.caller());

    FCH_table1 myTable = selection.getFirst();

    while (myTable)
    {
       //here the processing logic
       info(myTable.Firstname);

       myTable = selection.getNext();
    }
}


Create a Menu Item

image

Add a new Process Button on the form

In the Action Pane node, expand the action pane tab labelled HomeTab and add a new Button Group. Add to it a menuItemButton

image


Create a details Form

  1. In the AOT, right-click Forms, click New Form from template, and then click DetailsFormMaster
  2. Expand Designs and then click Design. In the Properties window click Caption, and then specify the label you want to appear in the title of the form.
  3. Find the table you want to add as a form data source. Drag the table to the Data Sources node of the form.
  4. To set it as primary datasource on Designs click the DataSource property and then select the table you want to use as the primary data source for the form.
  5. In the property sheet, click the TitleDataSource property and then select the table that contains the field values that you want to appear in the title bar of the form.
  6. Add Fields (Note, All details forms have two view modes Details view and Grid view: use buttons in the status bar or action pane to switch between the details view and the grid view)
    • Add fields to the editable grid
      • expand TabPageGrid, expand GridGroup, and then click HeaderGrid.
      • click the DataSource property and then select the table
      • from the datasource drag that field onto the grid (drag only the fields you typically use the editable grid to quickly find and update a record.)
    • Add details fields on the header
      • Expand Design, expand Tab, expand TabPageDetails, and then expand HeaderDetailsTab. You should see the HeaderGeneral tab page. Drag from the datasource the fields you want to be able to edit.
      • To organize and label groups of fields, you can add one or more Group controls.
  7. Set the header
    1. create a dataMethod and set it to the headerTitle

      image


      public display Description dispHeaderTitle()
      {
          return FCH_table1.Firstname;
      }
      


you will get something like this:

image


specify the default action for the List page grid to open the details page with double click

  1. create a Display menu item for the details form:

    image
  2. expand the button group labeled MaintainGroup, right-click the menu item button labeled ViewButton and set the MenuItemName property as the above menu item

    image
  3. modify the edit button:

    image

No comments:

Post a Comment