custom/Extension/modules/<Module>/Ext/Vardefs/<descriptive_name>.php
Custom fields allow you to add new data attributes to any SuiteCRM module without modifying core files. There are two ways to add them: through Studio (the GUI) or directly via Vardefs (code). Both are upgrade-safe when done correctly.
Studio is the recommended starting point for simple fields. Navigate to Admin > Studio, select the module, then Fields > Add Field. Studio generates the necessary Vardef extension files automatically.
Even when using Studio, always verify the generated files in custom/Extension/modules/<Module>/Ext/Vardefs/ before deploying to production. Studio-generated fields are fully upgrade-safe.
For programmatic control — required when building a Module Installer package or when you need field types Studio doesn’t expose — add fields directly via the Extension Framework.
Create a file at:
custom/Extension/modules/<Module>/Ext/Vardefs/<descriptive_name>.php
For example, to add a field to the Accounts module:
custom/Extension/modules/Accounts/Ext/Vardefs/acct_custom_fields.php
<?php
$dictionary['Account']['fields']['priority_level_c'] = array(
'name' => 'priority_level_c',
'vname' => 'LBL_PRIORITY_LEVEL',
'type' => 'varchar',
'len' => 100,
'comment' => 'Custom priority level field',
);
After saving the file, run a Quick Repair and Rebuild (Admin > Repair) and execute the generated SQL to add the column to the database.
| Type | Description |
|---|---|
|
Variable-length string. Use |
|
Unlimited-length text area. |
|
Integer. |
|
Decimal number. Use |
|
Checkbox (true/false). |
|
Date field. |
|
Date and time field. |
|
Monetary value, respects the user’s currency setting. |
|
A relationship field that displays a linked record’s name. Requires |
|
Drop-down list. Requires a |
|
Multi-select list. Same as |
|
File upload field. |
|
URL field, renders as a clickable link. |
<?php
// custom/Extension/modules/Accounts/Ext/Vardefs/acct_status_field.php
$dictionary['Account']['fields']['account_tier_c'] = array(
'name' => 'account_tier_c',
'vname' => 'LBL_ACCOUNT_TIER',
'type' => 'enum',
'options' => 'account_tier_list',
'len' => 100,
);
Define the drop-down list in a language file:
<?php
// custom/Extension/application/Ext/Language/en_us.account_tier.php
$app_list_strings['account_tier_list'] = array(
'' => '',
'bronze' => 'Bronze',
'silver' => 'Silver',
'gold' => 'Gold',
'platinum' => 'Platinum',
);
<?php
$dictionary['Account']['fields']['primary_contact_name_c'] = array(
'name' => 'primary_contact_name_c',
'vname' => 'LBL_PRIMARY_CONTACT',
'type' => 'relate',
'module' => 'Contacts',
'id_name' => 'primary_contact_id_c',
'rname' => 'full_name',
'len' => 255,
);
$dictionary['Account']['fields']['primary_contact_id_c'] = array(
'name' => 'primary_contact_id_c',
'type' => 'varchar',
'len' => 36,
);
To index your custom field for faster search queries:
<?php
$dictionary['Account']['indices'][] = array(
'name' => 'idx_acct_priority_level',
'type' => 'index',
'fields' => array('priority_level_c'),
);
After adding a field via Vardefs, it will not appear in views automatically. Add it to the desired layout through Studio > [Module] > Layouts, or programmatically via a custom editviewdefs.php/detailviewdefs.php file. See the Metadata page for layout customisation details.
Add a display label for your field in a language extension file:
<?php
// custom/Extension/modules/Accounts/Ext/Language/en_us.priority_level.php
$mod_strings['LBL_PRIORITY_LEVEL'] = 'Priority Level';
Custom fields added via Studio are automatically suffixed with _c (e.g. priority_level_c). When adding fields manually, follow the same convention to distinguish custom fields from core fields and avoid upgrade conflicts.
Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.