Skip to main content

Task

Configure all EntityFields, who have a display value, i.e., a value that is shown in the client instead of the actual (internal) value of the field. Particularly, these are the following EntityFields:

  • Car_entity:
  • CarDriver_entity:
    • CONTACT_ID (show salutation and full name instead of the UID)
  • CarReservation_entity:
    • CAR_ID (show the title of the manufacturer's keyword and the type)
    • CARDRIVER_ID (show salutation and full name instead of the UID)
tip

Here you can find a generic description of value and display value.

important

Always keep in mind that a value/displayValue calculated via the RecordContainer (RecordFieldMapping's property expression) shows, in most cases, a better performance than a calculation via the EntityField's valueProcess/displayValueProcess. However, you still need the valueProcess, if an EntityField should be preselected (initialized) with a specific value in the EditView, when inserting a new dataset that is not yet in the database.


Solution

CarDriver_entity

We want the full name, including the salutation, to be displayed instead of the CONTACT_ID UID. For this purpose, we can simply borrow a function of Person_lib:

CONTACT_ID

import { result } from "@aditosoftware/jdito-types";
import { PersUtils } from "Person_lib";

result.string(PersUtils.getResolvingDisplaySubSql("CONTACT_ID"));

CarDriver_entity.db.CONTACT_ID.displayValue.expression.js

CarReservation_entity

CAR_ID

We do not want to see the UID, but the title of the manufacturer's keyword, along with the type:

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

As we want the same to be displayed also in the CarReservationEdit_view, after selecting a car, we also need a displayValueProcess:

import { result, vars } from "@aditosoftware/jdito-types";
import { newSelect } from "SqlBuilder_lib";
import { KeywordUtils } from "KeywordUtils_lib";

let carId = vars.get("$field.CAR_ID");

if (carId) {
var res = newSelect("CONCAT("
+ KeywordUtils.getResolvedTitleSqlPart("CarManufacturer", "CAR.MANUFACTURER")
+ ", ' ', CAR.TYPE)")
.from("CAR")
.whereIfSet("CAR.CARID", carId)
.cell();

result.string(res);
}

CarReservation_entity.CAR_ID.displayValueProcess.js

CARDRIVER_ID

We do not want to see the UID, but the salutation and the full name of the related contact person. Like we did for CarDriver_entity's field CONTACT_ID (see above), we can simply borrow a function of Person_lib. Note: Here, we can directly use column CONTACT_ID, as the database table CARDRIVER has been joined in CarReservation_entity's db RecordContainer (see properties linkInformation and fromClauseProcess).

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 we want the same to be displayed also in the CarReservationEdit_view, after selecting a driver, we also need a displayValueProcess. Here, we can also use a function of Person_lib:

import { result, vars } from "@aditosoftware/jdito-types";
import { newSelect } from "SqlBuilder_lib";
import { PersUtils } from "Person_lib";

let carDriverId = vars.get("$field.CARDRIVER_ID");

if (carDriverId)
{
var contactId = newSelect("CARDRIVER.CONTACT_ID")
.from("CARDRIVER")
.whereIfSet("CARDRIVER.CARDRIVERID", carDriverId)
.cell();

if (contactId)
{
result.string(PersUtils.getResolvingDisplayValue(contactId));
}
}

CarReservation_entity.CARDRIVER_ID.displayValueProcess.js