Task
We have created the basic models required for handling cars and car drivers, manually. Now, as for the third data structure - car reservations - use blueprints for creation and configuration.
In this chapter, we will use existing blueprints provided by the ADITO xRM project. If you are interested in a more detailled description and in information on how to create your own blueprints, please check chapter Blueprints.
Solution
First, create the database table CARRESERVATION with all required columns.

Update the Alias Definition.

Subsequently use the 2 blueprints for creating Entity, RecordContainer, Context, and Views:


(...you may skip the 4 standard columns - DATE_NEW, etc.)


Rework
Now that the models have been created, some minor rework of the EntityFields is required, e.g., for the properties
title(replace provisionaly titles, both of CarReservation_entity (titleandtitlePlural) and of its EntityFields' titles)contentType/resolution(set a resolution, e.g. DAY, for all EntityFields ofcontentType= DATE)mandatory(by default, the blueprint sets mandatory=true for all EntityFields, except the primary key. This needs to be double-checked, because some EntityFields might be optional))isFilterable(property of RecordFieldMappings): Set true for all fields that should be selectable as filter criteria in the filter component of the client.
Furthermore, select a suitable icon for the Entity/the Context property icon or iconId, respectively.
Add the calculated EntityField "mileageStart" (without logic, for the meantime).
For every View, create and configure the common ViewTemplates, including a reasonable assignment of EntityFields.
Add the new Context to the Global Menu.
Finally, deploy and add some test data.
As for the keyword field CURRENCY and the foreign key fields CAR_ID and CARDRIVER_ID, simply add some data manually. We will enable a selection via dropdown/lookup later.
The result may look like this:

DisplayValues
(Find more information here.)
To show the car's name (manufacturer and type, e.g., "BMW 328i") instead of its ID and to show the driver's name instead of their ID, we add logic for a displayValue in the expression properties of the respective RecordFieldMappings (please note that this requires an extension of the SQL's FROM clause, see below):
- Open CarReservation_entity in the Navigator.
- In the Navigator, unfold CarReservation_entity and then navigate to RecordContainers > db > CAR_ID.displayValue.
- Double-click on CAR_ID.displayValue
- Enter the following code in property
expression.
import { result } from "@aditosoftware/jdito-types";
import { KeywordUtils } from "KeywordUtils_lib";
result.string("CONCAT(( "
+ KeywordUtils.getResolvedTitleSqlPart("CarManufacturer", "CAR.MANUFACTURER")
+ "), ' ', CAR.TYPE)");
CarReservation_entity.db.CAR_ID.displayValue.expression.js
Then, do the analog steps for showing the name of the car driver:
- Open CarDriver_entity in the Navigator.
- In the Navigator, unfold CarDriver_entity and then navigate to RecordContainers > db > CARDRIVER_ID.displayValue.
- Double-click on CARDRIVER_ID.displayValue
- Enter the following code in property
expression.
import { result } from "@aditosoftware/jdito-types";
import { PersUtils } from "Person_lib";
result.string(PersUtils.getResolvingDisplaySubSql("CONTACT_ID"));
CarReservation_entity.db.CARDRIVER_ID.displayValue.expression.js
As mentioned before, the above code will only work, if we extend the FROM clause of the SQL statement of CARRESERVATION's dbRecordContainer: In the project tree, double-click on CarReservation_entity, then switch to the Navigator window and open CarReservation_entity > RecordContainers > db; click on "db" and open property fromClauseProcessin the property window, via the three-dotted button. There, enter the following code.
import { result } from "@aditosoftware/jdito-types";
import { newWhere, SqlBuilder } from "SqlBuilder_lib";
var from = new SqlBuilder()
.from("CARRESERVATION")
.leftJoin("CARDRIVER", "CARRESERVATION.CARDRIVER_ID = CARDRIVER.CARDRIVERID")
.leftJoin("CAR", "CARRESERVATION.CAR_ID = CAR.CARID")
result.string(from.toString());
CarReservation_entity.db.fromClauseProcess.js
LinkedContext
Set the EntityField CAR_ID's property linkedContext to "Car", and CARDRIVER_ID's property linkedContext to "CarDriver". Then, in the client, these 2 fields will appear with a link that will open the respective car/car driver in the MainView of the configured Context.
Furthermore, in Context CarDriver, set the EntityField CONTACT_ID's property linkedContext to "Person", enabling a quick jump to the Contex "Person":
If you are in CarDriverPreview_view, you can now click the "eye" icon (to the right of the driver's name), in order to show the driver's contact data in the PersonPreview_view.