Custom Fields

From WHMCS Documentation

Revision as of 21:10, 11 December 2014 by Samcraven (talk | contribs) (Regular Expression Validation)

Custom fields allow you to collect additional information from your clients. WHMCS allows you to setup an unlimited number of customer fields which apply to clients, individual products & services and/or support departments. They can be set as either public or admin only for private use.

Common examples are questions like how did you find out site, do you want to join the mailing list, VAT/Tax Number, etc...

Supported Field Types

  • Text Box - for text entry
  • Dropdown Menu - for a selection of options to choose from
  • Tick Box - for a yes/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. These can be set to Show on Order Form if you want the client to enter them or left as admin area only for private entries. The client can view and edit the field values from the client area unless they are set to admin only.

Product Custom Fields

Products you create can also have custom fields added to them which are then shown to the user during the order process. This allows you to collect further information specific to an individual product. These are set when configuring a product in Setup > Products/Services > Products/Services > Edit > Custom Fields tab . Some modules require specific fields are setup and will be explained in the documentation for that module.

Support Custom Fields

Custom fields for support are set per department and allow you to ask users for additional information when opening tickets. This is often used for things such as current usernames & passwords, etc... These are configured 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. Just 2 examples of what you might find this useful for are:

  • If you have a client custom field for a Tax ID or VAT Number
  • If you have a product custom field containing a Username or Reference for the clients product

So how do you do it? Well it's really simple. Both the client & product field types support this, and to enable it all you need to do is tick the checkbox labelled Show on Invoice where you configure the custom fields (either in Setup > Client Custom Fields or the Custom Fields tab of the product config).

In the case of client custom fields, they will then be shown under the name & address information on the invoice, and in the case of product custom fields they show as part of the line item descriptions for those products.

Displaying Custom Fields in Emails

Custom fields can be displayed in email templates using merge fields. The relevant documentation can be found at Email_Templates#Merge_Fields.

Regular Expression Validation

The regular expression validation rules allow you to define what value the field can take. The user won't be allowed to proceed until it passes the validation rule. Some common examples you might want:

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, alpha-numeric, and allowing 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}$/