Formulas - rodekruis/EspoCRM-knowledge-base GitHub Wiki
You can find widely used formulas in EspoCRM.
Given an Integer field age
and an Enum field ageGroup
if (age < 5) {
ageGroup = "0-4";
} else if (age < 18) {
ageGroup = "5-17";
} else if (age < 60) {
ageGroup = "18-59";
} else {
ageGroup = "60+";
};
Given an Integer field age
and a Date field dateOfBirth
age = datetime\diff(datetime\today(), dateOfBirth, 'years');
Also see: datetime - EspoCRM Documentation
name = <fieldname>;
This name will also show if there is relationships and the related record is shown in the layout.
record\attribute(ENTITY_TYPE, ID, ATTRIBUTE)
For example get the date of visit for a patient record, where the Patient and Visit entities are related:
$refField = record\attribute(‘Visit’, visitId, ’dateOfVisit’);