How to do it...

To create the order line table, follow these steps:

  1. Create a new table named ConWHSVehicleServiceLine.
  2. Drag the following EDTs onto the table:
    • ConWHSVehicleServiceId
    • LineNum
    • ItemId (you may receive an error if you haven't referenced Application Suite)
    • ItemName
    • ConWHSVehicleServiceStatus
  1. Remove the ConWHSVehicle prefixes.
  2. 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.
  1. Make ItemId mandatory and only allow it to be edited on creation.
  2. 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.
  3. 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

  1. 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

  1. 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.
  2. 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.

  1. 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;
  1. 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();
}
  1. 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;
}
}
  1. Once complete, save and close the editors.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.223.123