Although AX is shipped with a standard set of info parts placed on key forms throughout the system, we often find that our users require different information to be made available. An example of an info part is displayed on the right-hand pane of the All loads list page found by navigating to Transportation management | Common | Loads | All loads.
The data that is displayed on the info part is determined by a query. We use the query to define the data that will be displayed, and also to define how this relates to the form where the info part is placed. To demonstrate this, we will add a part to the All loads list page that will show vehicle information.
First, we will construct a query that defines a path from the load table to our vehicle table. This will have to go through the appointment table's relations to link to the vehicle created in the previous chapter.
The query structure doesn't need to include the load table itself, as the appointment table already has a relation defined. Queries used in any part must be written for performance and should only contain fields actually used in the part. We therefore don't create a generic reusable query, but a query specifically for a part.
Our part will need the following fields:
Before we start, we need to create a new relation on the TMSAppointment
table that connects the ConFMSVehicleTableTruck
foreign key to ConFMSVehicleTable.RecId
. This is because the current relation is to the inherited truck table, and we really need a relation to the base vehicle table. This becomes more apparent when we add parts to the vehicle list page, as this will show a combined list of all vehicle types. The only commonality is that they all extend ConFMSVehicleTable
.
There are two ways we can do this, add a new foreign key relation on TMSAppointment
and update the code to set the foreign key, or use the same field as the relation to ConFMSVehicleTable
. We can justify using the same key as we can say that the main vehicle is a truck. To do this, follow these steps:
TMSAppointment
to ConFMSVehicleTable
and update the required properties as before. You must set the RelatedTableRole
property. The relation should be done by right-clicking on the new relation and selecting New | Foreign Key | Single field AlternateKey based. We want RecId
as the relation.ConFMSVehicleTable
to ConFMSVehicleTableTruck
.ConFMSVehicleTable
. We don't need this field now, as our relation is using ConFMSVehicleTableTruck
as the foreign key. Delete this new field.To create the query for the vehicle information info part, follow these steps:
ConFMSVehicleAppointmentPart
. The Part
suffix is a convention, and it is important to highlight to other developers that it is a part query.TMSAppointment
to the Data Sources node.No
, as we don't want any fields from this data source.ConFMSVehicleTable
to the Data Sources node under TMSAppointment
.Yes
, noting that all of the table's fields have been automatically added under the Fields node. Now, change it to No
and they are still there. This is a nice trick to add all the fields to the field list when we want most but not all fields.VehicleId
, VehicleStatusId
, VehRegNo
, and VehicleGroupId
. Verify that Dynamic is set to No
once finished.ConFMSVehicleTable
, set Relations to Yes
.ConFMSVehicleTable
relation, which happens to be correct.ConFMSVehServiceTable
to the Data Sources node under ConFMSVehicleTable
.NextServiceDate
field. Dynamic must be set to No
once finished.ConFMSVehServiceTable
, set JoinMode to OuterJoin
and Relations to Yes
. We are using the outer join, as we will still want to show the vehicles without service data.Yes
.ConFMSVehServiceTable
, Field to NextServiceDate
, and Direction to Descending
.The query structure should look like what is shown in the following screenshot:
You may notice that we didn't include the fields used in the joins to our tables. AX will handle this for us.
Next, we can create the info part, which is done by the following steps:
ConFMSVehicleAppointmentPart
.ConFMSVehicleAppointmentPart
.VehicleGroup
.No
.Yes
. In our case, we want just the information in a form view, so we leave it as No.ConFMSVehicleTable
and DataField to VehicleId
. Copy the VehicleId
field name to the Name property.VehicleId
field, set Style as TitleField
.We now have to create a display menu item so that it can be added to a form. This is done as follows:
ConFMSVehicleAppointmentPart
.Vehicle information
and create a new label (don't use the existing GLS label), remembering to set Comments to Con Vehicle information
.InfoPart
and Object to ConFMSVehicleAppointmentPart
.To add the All loads list page, our first task is to locate it in the AOT. The easiest way is to navigate the Menus node in the AOT as if you are navigating through the interface. The properties of the All loads node reveal that the menu item is WHSLoadPlanningListPage
. The Object property of this menu item has the same name, so this is the form.
To add the WHSLoadPlanningListPage
info part, follow these steps:
WHSLoadPlanningListPage
form onto the Forms node of your project.ConFMSVehicleAppointmentPart
menu item onto the Parts node of WHSLoadPlanningListPage
.DataSource
is WHSLoadTable
, which is correct, as this is how we intend to relate to TMSAppointment
.TMSAppointment.WHSLoadTable
. This is the relation defined between WHSLoadTable
and TMSAppointment
, which is also correct.First, we should test the info part. As part of our testing in Chapter 4, Creating Business Logic and Hooking into Core AX, we created a vehicle and linked it to an appointment. To test this part, we need to associate it to a load. This is done on the Reference fast tab in the Appointment Scheduling form.
To test the info part, right-click on the WHSLoadPlanningListPage
form and select Open. Move through the records until you reach the load that was referenced against the appointment. It should display information as shown in the following screenshot:
The vehicle ID appears as a heading, and the other fields appear as a form, which is as expected. After clicking on More, we are shown the Appointment Schedule form, but the Vehicle details form would be more appropriate.
We can change this by the following steps:
ConFMSVehicleTable
.If you open the other list pages by going to Transportation management | Common | Loads, you will see that they all contain our info part. These are secondary list pages, which are the same form configured to show subsets of the loads.
You can also add more actions to the part, but be careful not to clutter the design as this would detract from the purpose of showing key data.
To add another link to the Appointment Schedule form as an action, follow these steps:
TMSAppointment
and copy the Name property also.A new link is added below the More link, labeled Appointment Scheduling, as shown in the following screenshot:
Finally, we should add the info part to the All shipments list page. The form is WHSShipPlanningListPage
and you simply have to drag the part's menu item as before onto the Parts node. Remember to click on the DataSourceRelation property to ensure that this is correct.
3.145.17.18