This topic provides an example of how to create a new entity using one of the sample application entities to illustrate the process.
A key piece of database schema in the Motor Loaner System is the Rental Agreements entities. The need for this entity is documented as DR6: Rental Agreements Form Information in the About the Data Requirements for the Sample Application topic and the design for this entity is described in About the Creation of Entities for the Sample Application.
After a careful review of the design of the entire application, the developer created the entities for the Motor Loaner system. (Note that you should carefully design your entity and application before creating new records in the Entities service.) The developer followed these steps to design the Rental Agreements entity in Aptify:
Rental Agreements was one of the last entities to be created for the Motor Loaner System since it includes links to the Vehicles (which in turn links to numerous other entities), Associates, and Customers entities. These other entities needed to exist prior to the Rental Agreements entity so the appropriate links could be created. |
Info Tab > Help Text: Enter text in the Help Text field on the Info tab to provide field level help for this item (such as "Vehicle to be rented by the Customer (Vehicle's Year, Manufacturer, Model and VIN) (Required field during Check-Out Process)").
Note that when populated with a Vehicles record, this link box displays the value from the field in the Vehicles entity that has the Is Name Field option checked. In this case, that is the YearMfrModelVIN, which is a calculated virtual field that aggregates the Manufacturer/Model/Year field from the Vehicle Models entity with the Vehicle's VIN. Also, note that since Rental Agreements is a transaction-based entity, its records will be identified by ID number, so none of the fields will have the Is Name Field check box selected. |
Following the same process used to create the VehicleID field and virtual field, add two additional sets of Linked Fields/Virtual Fields for CheckOutClerkID (identifies the Associate who initiated the rental check-out) and CustomerID (the customer who is renting/rented the vehicle). Additional details on these fields appear in the following table:
Field Name | Field Type | Notes |
CheckOutClerkID | Link Box | Required field. Link to Associates entity's ID field. |
CheckOutClerk | Joined Virtual Field | Full name of associate who performed check-out procedure. |
CustomerID | Link Box | Required field. Link to Customers entity's ID field. |
CustomerName | Joined Virtual Field | Full name of the customer renting the vehicle. |
Add the remaining fields related to the check-out portion of the rental agreement, as identified in the table below:
Field Name | Field Type | Notes |
RentalDate | Date Selection Field | Required field. Use a Default Value of GETDATE() to automatically populate this field with the current date when opening new records. |
ExpectedReturn | Date Selection Field | Required field. The expected return date of the rental. |
StartingMileage | Standard Text Field | Required field. This is a number-based field; use a data type of int(4). |
StartingFuelLevel | Standard Combo Drop-down List | Required field. Use a data type of nvarchar(50) and specify the following static values:
Note that as a required field, the first record in the value list (Empty, in this case) is the de facto default when a Default Value is not specified. |
StartingCondition | Standard Combo Drop-down List | Required field. Use a data type of nvarchar(50) and specify the following static values:
Note that as a required field, the first record in the value list (Acceptable, in this case) is the de facto default when a Default Value is not specified. |
CheckOutComments | Multi-Line Text Field | This field is not required. Use nvarchar(max) as the data type. Enter Check-Out Comments as both the Display Name and as the Category to add a Check-Out Comments tab to the generated Rental Agreements form. |
Note that none of these fields are required in the entity definition. In other words, none of these fields require a value to save a new Rental Agreements record, since a new record is typically saved with check-out details only. However, most of these fields are required when completing a vehicle check-in. The Rental Agreements entity object will handle this type of validation (see Developing Entity Plug-in Objects).
Field Name | Field Type | Notes |
CheckInClerkID | Link Box | Not required. Link to Associates entity's ID field. |
CheckInClerk | Joined Virtual Field | Full name of associate who performed check-in procedure. Note the Join Type is Optional since CheckInClerkID is not required. |
ReturnDate | Date Selection Field |
|
ReturnMileage | Standard Text Field | This is a number-based field; use a data type of int(4). |
ReturnFuelLevel | Standard Combo Drop-down List | Use a data type of nvarchar(50) and specify the following static values:
|
ReturnCondition | Standard Combo Drop-down List | Use a data type of nvarchar(50) and specify the following static values:
|
CheckInComments | Multi-Line Text Field | Use nvarchar(max) as the data type. Enter "Check-In Comments" as both the Display Name and as the Category to add a Check-In Comments tab to the generated Rental Agreements form. |
When finished, the Entities record's Fields tab looks like this:
The Rental Agreements entity included with the sample application also includes one additional virtual field not displayed in the figure above: YearMfrModel, which is a virtual field via the VehicleID to the Vehicles entity's YearMfrModel field. This virtual field was created for use within the Top 5 Rented Vehicles in Last Month view in the Manager's Dashboard. |
The Rental Agreements entity in the sample application also includes two code-based configurations: an Entity Object and a Layout Control. |
See Developing Entity Plug-in Objects for information on the Entity Object. See Developing Form Templates for information on the Layout Control. Note that part of the functionality of the Layout Control is to disable Check-In related fields for new Rental Agreements record.