Field Constants¶
calServer provides placeholder constants that can be used in field defaults, report templates, and mailer templates. The constants are replaced with current values at runtime.
Date and Time¶
Basic timestamps for automatic field pre-population:
| Constant | Description | Example Value |
|---|---|---|
[CURRENT_DATE] |
Current date | 2026-02-26 |
[CURRENT_TIME] |
Current time | 14:30:00 |
[CURRENT_DATETIME] |
Date and time | 2026-02-26 14:30:00 |
[DUE_DATE] |
Due date (from configuration) | 2026-06-26 |
Date Components¶
Individual components of the current date:
| Constant | Description |
|---|---|
[YYYY] |
Current year (four digits) |
[MM] |
Current month (two digits) |
[DD] |
Current day (two digits) |
Time Period Constants¶
Predefined start and end dates for report periods:
| Constant | Description |
|---|---|
[CURRENTMONTH_STARTDAY] |
First day of the current month |
[CURRENTMONTH_ENDDAY] |
Last day of the current month |
[LASTMONTH_STARTDAY] |
First day of the previous month |
[LASTMONTH_ENDDAY] |
Last day of the previous month |
[MONTHBEFORE_LASTMONTH_STARTDAY] |
First day of the month before last |
[MONTHBEFORE_LASTMONTH_ENDDAY] |
Last day of the month before last |
[CURRENTYEAR_STARTDAY] |
First day of the current year |
[CURRENTYEAR_ENDDAY] |
Last day of the current year |
Date Calculations¶
The current date can be combined with offsets. The syntax is:
Supported units:
| Unit | Meaning | Example |
|---|---|---|
D |
Days | [CURRENT_DATE]+[14D] -- 14 days in the future |
M |
Months | [CURRENT_DATE]-[2M] -- 2 months in the past |
Y |
Years | [CURRENT_DATE]+[1Y] -- 1 year in the future |
Status Constants¶
Placeholders for the current status of a record:
| Constant | Description |
|---|---|
[STATUS_NAME] |
Status label |
[STATUS_SHORT] |
Status abbreviation |
[STATUS_COUNT] |
Status counter |
Additionally, category constants are available:
| Constant | Description |
|---|---|
[CATEGORY_NAME] |
Category label |
[CATEGORY_SHORT] |
Category abbreviation |
[CATEGORY_COUNT] |
Category counter |
Counter Constants¶
Two global counters for sequential numbering:
| Constant | Description |
|---|---|
[GLOBAL_COUNTER_1] |
Global counter 1 |
[GLOBAL_COUNTER_2] |
Global counter 2 |
The counters can be reset via the CLI command ./yiic resetcounter run.
User Constant¶
| Constant | Description |
|---|---|
[CURRENT_USER] |
Username of the currently logged-in user |
Field Reference Constants¶
Field reference constants allow the value of another field in the same record to be used as a default value.
I-Series (Inventory Fields)¶
The constants [I4201] to [I4262] reference the configurable inventory fields. The placeholder is replaced with the current value of the respective field in the associated inventory record.
Example: If [I4201] is set as the default value in a calibration field, the value of inventory field I4201 (typically the device description) is automatically applied when creating a new calibration.
C-Series (Calibration Fields)¶
The constants [C2301] to [C2396] reference the configurable calibration fields using the same principle.
Email Template Constants¶
Additional placeholders are available in email templates:
| Constant | Description |
|---|---|
[EMAIL] |
Recipient's email address |
[NAME] |
Username |
[FIRSTNAME] |
First name |
[LASTNAME] |
Last name |
[FULLNAME] |
Full name |
[FIRM] |
Company name |
[NUMBER] |
Device or order number |
[STATUS] |
Current status |
[DOMAIN] |
Domain of the calServer instance |
Usage¶
Constants are used in the following areas:
- Field defaults -- Default values in the field configuration (Administration > Field Management)
- Report templates -- Parameters in JasperReports templates
- Email templates -- Placeholders in subject and message body of mailer actions
- Rules -- Conditions and actions in rule processing
The field constants are configured in httpdocs/protected/config/constants.php in the field_configuration_default_value array.