To create the order line table, follow these steps:
- Create a new table named ConWHSVehicleServiceLine.
- Drag the following EDTs onto the table:
- ConWHSVehicleServiceId
- LineNum
- ItemId (you may receive an error if you haven't referenced Application Suite)
- ItemName
- ConWHSVehicleServiceStatus
- Remove the ConWHSVehicle prefixes.
- The ServiceId and LineNum fields are usually controlled from code, so make them read-only and mandatory (this ensures that the code that sets them has run before the user saves the line).
The LineNum field is usually used to order the lines and can be made not visible if this isn't to be displayed in the user interface. All visible (non-system) fields should either be in a field group or made not visible.
- Make ItemId mandatory and only allow it to be edited on creation.
- Create a unique index called ServiceLineIdx and add the ServiceId and LineNum fields. We will use this as a clustered index as it will naturally sort the lines on the form.
- Add a relation to ConWHSVehicleServiceTable, but service lines are contained within a service order record, so complete it as follows:
Parameter |
Value |
Name |
ConWHSVehicleServiceTable |
Related Table |
ConWHSVehicleServiceTable |
Cardinality |
ZeroMore |
Related Table Cardinality |
ZeroOne |
Relationship Type |
Composition |
On Delete |
Cascade |
- Add a relation to InventTable on ItemId as follows:
Parameter |
Value |
Name |
InventTable |
Related Table |
InventTable |
Cardinality |
OneMore |
Related Table Cardinality |
ExactlyOne |
Relationship Type |
Association |
On Delete |
Restrict |
- Create an Overview group to control what appears on the lines and add all fields. In our case, this is sufficient. We would usually have many more fields on a line, and we would organize the fields into logical groups that are used in the form design.
- Update the table's properties as follows:
Property |
Value |
Label |
Vehicle service order lines |
Title Field 1 |
ItemId |
Title Field 2 |
ItemName |
Cache lookup |
Found |
Clustered Index |
ServiceLineIdx |
Primary Index |
SurrogateKey (default) |
Table Group |
WorksheetLine |
Created By Created Date Time Modified By Modified Date Time |
Yes |
Developer Documentation |
ConWHSVehicleServiceLine contains vehicle service order line records. |
- The Find and Exist methods will need two keys in this case, ServiceId and LineNum. The select statement clause should be written as follows:
select firstonly * from serviceLine
where serviceLine.ServiceId == _id
&& serviceLine.LineNum == _lineNum;
- Finally, we will need to initialize the ItemName field from the item table; first, create the initFromInventTable method. We will follow the same pattern as we did earlier and write the following lines of code:
public void initFromInventTable(InventTable _inventTable)
{
this.ItemName = _inventTable.itemName();
}
- Override the modifiedField method and call the preceding method as shown here:
public void modifiedField(FieldId _fieldId)
{
super(_fieldId);
switch (_fieldId)
{
case fieldNum(ConWHSVehicleServiceLine, ItemId):
this.initFromInventTable(
InventTable::find(this.ItemId));
break;
}
}
- Once complete, save and close the editors.