Difference between revisions of "Custom Fields"
Line 1: | Line 1: | ||
− | Custom fields allow you to collect additional information from your clients. WHMCS allows you to | + | Custom fields allow you to collect additional information from your clients. WHMCS allows you to set up an unlimited number of customer fields that apply to clients, individual products and services, and support departments. You can set them as either admin-only for private use or public. |
− | + | For example, you might create custom questions like how a client found your site, whether they want to join the mailing list, or their VAT/Tax Number. | |
==Supported Field Types== | ==Supported Field Types== | ||
− | *Text Box | + | *Text Box — For a text entry. |
− | *Dropdown Menu | + | *Dropdown Menu — For a selection of preset options. |
− | *Tick Box | + | *Tick Box — For a yes-or-no answer. |
− | *Textarea | + | *Textarea — For a long text entry of multiple lines. |
==Types of Custom Fields== | ==Types of Custom Fields== | ||
Line 14: | Line 14: | ||
===Client Custom Fields=== | ===Client Custom Fields=== | ||
− | You can create client profile related fields in '''Setup > Custom Client Fields'''. | + | You can create client profile-related fields in '''Setup > Custom Client Fields'''. Set these to '''Show on Order Form''' if you want the client to enter them. You can also leave them as only visible in the admin area, for private entries. The client can view and edit the field values from the client area unless you set them to admin only. |
===Product Custom Fields=== | ===Product Custom Fields=== | ||
− | Products you create can also | + | Products that you create can also include custom fields, which the user then views during the order process. This allows you to collect further information that's specific to an individual product. You can set these when you configure a product in '''Setup > Products/Services > Products/Services > Edit > Custom Fields tab '''. Some modules require specific fields, which you can find in the documentation for that module. |
===Support Custom Fields=== | ===Support Custom Fields=== | ||
− | + | Set custom fields for support on a per-department basis. They allow you to ask users for additional information when opening tickets. The system can use this for things like current usernames and passwords. Configure these in '''Setup > Support > Support Departments > Edit > Custom Fields tab''' | |
==Displaying Custom Fields on Invoices== | ==Displaying Custom Fields on Invoices== | ||
− | There are times when you might want custom fields to appear on invoices. | + | There are times when you might want custom fields to appear on invoices. For example: |
− | * | + | *You have a client custom field for a Tax ID or VAT Number. |
− | * | + | *You have a product custom field containing a Username or Reference for the client's product. |
− | + | The client and product field types support this. To enable this, check the '''Show on Invoice''' checkbox when you configure the custom fields (either in '''Setup > Client Custom Fields''' or the '''Custom Fields''' tab of the product configuration). | |
− | + | Client custom fields will display under the name and address information on the invoice. Product custom fields display as part of the line item descriptions for those products. | |
− | + | If you enable "Store Client Data Snapshot" under Setup > General Settings > Invoices tab and then create or edit a custom field after invoice creation, the invoice won't reflect those changed values and new fields. However, future invoices will show them. | |
==Displaying Custom Fields in Emails== | ==Displaying Custom Fields in Emails== | ||
− | + | You can add custom fields to email templates using merge fields. For more information, see [[Email_Templates#Merge_Fields|Email Templates]]. | |
==Displaying Custom Fields on Pages== | ==Displaying Custom Fields on Pages== | ||
− | To display custom fields on service-related pages, the merge fields take the following format: | + | To display custom fields on service-related pages, the merge fields take the following format, where <tt>fieldname</tt> is the name of the custom field, lowercase with no spaces: |
− | < | + | <div class="source-cli"> |
{$client_custom_field_fieldnamehere} | {$client_custom_field_fieldnamehere} | ||
− | </ | + | </div> |
− | + | For example, for IP address, the merge field would be: | |
− | < | + | <div class="source-cli"> |
{$service_custom_field_ipaddress} | {$service_custom_field_ipaddress} | ||
− | </ | + | </div> |
− | For fields with Friendly Names, the friendly name | + | For fields with Friendly Names, use the friendly name, rather than the machine name, to reference the field. For example, if the field name is: |
<source lang="php">CustomerType</source> | <source lang="php">CustomerType</source> | ||
− | it | + | Reference it as: |
<source lang="php"> | <source lang="php"> | ||
Line 63: | Line 63: | ||
</source> | </source> | ||
− | However, if the field name is using a friendly name like this: | + | However, if the field name is using a friendly name, like this: |
<source lang="php"> | <source lang="php"> | ||
Line 69: | Line 69: | ||
</source> | </source> | ||
− | it | + | Reference it as: |
<source lang="php"> | <source lang="php"> | ||
Line 76: | Line 76: | ||
===Multi-line Text Areas=== | ===Multi-line Text Areas=== | ||
− | For text area custom fields, data | + | For text area custom fields, you can enter data on multiple lines. By default, the system displays it in merge fields on a single line. To see the custom field data as it was entered in the field, use the following merge field: |
<source lang="php"> | <source lang="php"> | ||
{$client_custom_field_fieldnamehere|nl2br} | {$client_custom_field_fieldnamehere|nl2br} | ||
+ | </source> | ||
or | or | ||
+ | <source lang="php"> | ||
{$service_custom_field_ipallocation|nl2br} | {$service_custom_field_ipallocation|nl2br} | ||
</source> | </source> | ||
==Searching Custom Field Values== | ==Searching Custom Field Values== | ||
− | + | Use the appropriate list page to search for the values for custom client and product fields. You can search custom client fields via '''Clients > View/Search Clients > Search/Filter tab''' or search for custom product fields via '''Clients > Products/Services > Search/Filter tab'''. | |
<div class="docs-alert-success"> | <div class="docs-alert-success"> | ||
− | <span class="title">Tip: Searching | + | <span class="title">Tip: Searching Checkboxes</span><br /> |
− | + | To search a 'Tick Box' type custom field, enter "on" in the Custom Field Value field. This will display results that include the checked option. | |
</div> | </div> | ||
==Friendly Display Names== | ==Friendly Display Names== | ||
− | + | Sometimes, a module may require that you format a custom field value in a certain way, which may be hard for visitors to understand. WHMCS can display a friendly name to visitors on the order form, emails, and invoices, and still send the required machine code to the module. | |
[[File:Custom_field_friendly.png|thumb|Custom Field Friendly Names]] | [[File:Custom_field_friendly.png|thumb|Custom Field Friendly Names]] | ||
− | To achieve this use the format "required value|display value" | + | To achieve this, use the format "required value|display value". For example: |
*Disk Space|Your Web Quota | *Disk Space|Your Web Quota | ||
*10000MB|10 Gigabytes | *10000MB|10 Gigabytes | ||
*rbx01ssd|French Server - Solid State Drive | *rbx01ssd|French Server - Solid State Drive | ||
− | |||
==Regular Expression Validation== | ==Regular Expression Validation== | ||
− | The regular expression validation rules allow you to define what value the field can | + | The regular expression validation rules allow you to define what value the field can accept. The system won't allow the user to proceed until it passes the validation rule. For example: |
− | A domain name in the format "google.com" | + | A domain name in the format "google.com": |
/^([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/ | /^([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/ | ||
− | A username between 4 and 28 characters in length, | + | A username between 4 and 28 characters in length, allowing only alphanumeric characters and underscores: |
/^[a-z\d_]{4,28}$/i | /^[a-z\d_]{4,28}$/i | ||
Line 115: | Line 116: | ||
/^(\(?[0-9]{3,3}\)?|[0-9]{3,3}[-. ]?)[ ][0-9]{3,3}[-. ]?[0-9]{4,4}$/ | /^(\(?[0-9]{3,3}\)?|[0-9]{3,3}[-. ]?)[ ][0-9]{3,3}[-. ]?[0-9]{4,4}$/ | ||
− | A date in the format DD/MM/YYYY | + | A date in the format DD/MM/YYYY: |
/^\d{1,2}\/\d{1,2}\/\d{4}$/ | /^\d{1,2}\/\d{1,2}\/\d{4}$/ | ||
Line 121: | Line 122: | ||
<div class="docs-alert-warning"> | <div class="docs-alert-warning"> | ||
− | + | You must properly escape any forward slashes in your regular expression using back slashes: \/ | |
</div> | </div> |
Revision as of 14:13, 5 May 2020
Custom fields allow you to collect additional information from your clients. WHMCS allows you to set up an unlimited number of customer fields that apply to clients, individual products and services, and support departments. You can set them as either admin-only for private use or public.
For example, you might create custom questions like how a client found your site, whether they want to join the mailing list, or their VAT/Tax Number.
Contents
Supported Field Types
- Text Box — For a text entry.
- Dropdown Menu — For a selection of preset options.
- Tick Box — For a yes-or-no answer.
- Textarea — For a long text entry of multiple lines.
Types of Custom Fields
Client Custom Fields
You can create client profile-related fields in Setup > Custom Client Fields. Set these to Show on Order Form if you want the client to enter them. You can also leave them as only visible in the admin area, for private entries. The client can view and edit the field values from the client area unless you set them to admin only.
Product Custom Fields
Products that you create can also include custom fields, which the user then views during the order process. This allows you to collect further information that's specific to an individual product. You can set these when you configure a product in Setup > Products/Services > Products/Services > Edit > Custom Fields tab . Some modules require specific fields, which you can find in the documentation for that module.
Support Custom Fields
Set custom fields for support on a per-department basis. They allow you to ask users for additional information when opening tickets. The system can use this for things like current usernames and passwords. Configure these in Setup > Support > Support Departments > Edit > Custom Fields tab
Displaying Custom Fields on Invoices
There are times when you might want custom fields to appear on invoices. For example:
- You have a client custom field for a Tax ID or VAT Number.
- You have a product custom field containing a Username or Reference for the client's product.
The client and product field types support this. To enable this, check the Show on Invoice checkbox when you configure the custom fields (either in Setup > Client Custom Fields or the Custom Fields tab of the product configuration).
Client custom fields will display under the name and address information on the invoice. Product custom fields display as part of the line item descriptions for those products.
If you enable "Store Client Data Snapshot" under Setup > General Settings > Invoices tab and then create or edit a custom field after invoice creation, the invoice won't reflect those changed values and new fields. However, future invoices will show them.
Displaying Custom Fields in Emails
You can add custom fields to email templates using merge fields. For more information, see Email Templates.
Displaying Custom Fields on Pages
To display custom fields on service-related pages, the merge fields take the following format, where fieldname is the name of the custom field, lowercase with no spaces:
{$client_custom_field_fieldnamehere}
For example, for IP address, the merge field would be:
{$service_custom_field_ipaddress}
For fields with Friendly Names, use the friendly name, rather than the machine name, to reference the field. For example, if the field name is:
CustomerType
Reference it as:
{$client_custom_field_customertype}
However, if the field name is using a friendly name, like this:
CustomerType|Type of Customer
Reference it as:
{$client_custom_field_typeofcustomer}
Multi-line Text Areas
For text area custom fields, you can enter data on multiple lines. By default, the system displays it in merge fields on a single line. To see the custom field data as it was entered in the field, use the following merge field:
{$client_custom_field_fieldnamehere|nl2br}
or
{$service_custom_field_ipallocation|nl2br}
Searching Custom Field Values
Use the appropriate list page to search for the values for custom client and product fields. You can search custom client fields via Clients > View/Search Clients > Search/Filter tab or search for custom product fields via Clients > Products/Services > Search/Filter tab.
Tip: Searching Checkboxes
To search a 'Tick Box' type custom field, enter "on" in the Custom Field Value field. This will display results that include the checked option.
Friendly Display Names
Sometimes, a module may require that you format a custom field value in a certain way, which may be hard for visitors to understand. WHMCS can display a friendly name to visitors on the order form, emails, and invoices, and still send the required machine code to the module.
To achieve this, use the format "required value|display value". For example:
- Disk Space|Your Web Quota
- 10000MB|10 Gigabytes
- rbx01ssd|French Server - Solid State Drive
Regular Expression Validation
The regular expression validation rules allow you to define what value the field can accept. The system won't allow the user to proceed until it passes the validation rule. For example:
A domain name in the format "google.com":
/^([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/
A username between 4 and 28 characters in length, allowing only alphanumeric characters and underscores:
/^[a-z\d_]{4,28}$/i
A telephone number in the following format: (###) ###-####
/^(\(?[0-9]{3,3}\)?|[0-9]{3,3}[-. ]?)[ ][0-9]{3,3}[-. ]?[0-9]{4,4}$/
A date in the format DD/MM/YYYY:
/^\d{1,2}\/\d{1,2}\/\d{4}$/
See http://www.rexegg.com/regex-quickstart.html for a detailed guide.
You must properly escape any forward slashes in your regular expression using back slashes: \/