3.5.4. Customer Editor With a List of Orders

Do the following to display the list of Orders in the Customer’s edit screen:

  • Go to the GENERIC UI tab on the navigation panel. Choose customer-edit.xml screen and click Edit.

  • Go to the DATASOURCES tab on the screen designer page and click New.

  • Select the newly created datasource in the list. Its attributes will appear in the right part of the page.

  • Specify collectionDatasource in the Type field.

  • Select Order entity in the Entity list.

  • The data source identifier − ordersDs - will be automatically generated in Id field.

  • Select _local view in the View list.

  • Add the WHERE clause to the query generated in the Query field:

    select o from sales$Order o where o.customer.id = :ds$customerDs order by o.date

    The query contains orders selection criterion with ds$customerDs parameter. The parameter value named like ds${datasource_name} will contain id of the entity selected in datasource_name datasource at the moment, in this case it is the id of the Customer being edited.

    qs customer screen orders ds
  • Click Apply to save the changes.

  • Next go to the LAYOUT tab in the screen designer and find the Label component in the components palette. Drag this component to the screen components hierarchy panel and place it between fieldGroup and windowActions. Go to the PROPERTIES tab on the properties panel. Enter the label value Orders in the value field.

    qs customer screen label
    Tip

    If the application is intended to be used in multiple languages, use the localization button next to the value field to create the new message msg://orders and define label values in required languages.

  • Drag Table from the components palette to components hierarchy panel and place it between label and windowActions. Select this component in the hierarchy and specify table size in the PROPERTIES tab: set 100% in the width field and 200px in the height field. Choose orderDs from the list of available datasources. Then generate the table identifier using the generate_id button next to the id field: ordersTable.

    qs customer screen table
  • Click OK on the top panel to save the changes in the screen.