Working with custom fields

View name Description
custom_fields List all available custom fields.
Function name Description
cf(uid) Returns a relation which lists all custom fields for the given UID.
cf(uid, code) Returns the value of the specific custom field for the given UID.

Smile allows you to define custom fields within the Smile application, and many pre-existing database fields in Smile are actually implemented or presented as custom fields as well.

You can not access custom fields in the same way that you access regular database tables, so Smile public schema provides a set of SQL functions and tables to provide you a way to access to this data.

View name Description
custom_fields List all available custom fields.
Column name Description
code The custom field code, an identifier used to refer to the field from the ‘cf’ functions.
name A human readable name for the field, which is not otherwise used in Smile public schema.

The custom_fields table lists all of the available custom fields in the Smile database. Not all fields are used on every account or subscription.

To see a list of all the custom fields in a given Smile database, including both those built into Smile and those you have defined yourself, run the query:

SELECT * FROM custom_fields;

This will return a table similar to the following fragment:
             code             |              name
------------------------------+------------------------------
 billingAddressBuildingName   | Billing Address Building Name
 billingAddressCountry        | Billing Country
 billingAddressFloorNumber    | Billing Address Floor Number
 billingAddressLotNumber      | Billing Address Lot Number
 billingAddressPostcode       | Billing Postcode
 billingAddressState          | Billing State
 billingAddressStreetName     | Billing Street Name
 billingAddressStreetNumber   | Billing Street Number
 billingAddressStreetType     | Billing Street Type
 billingAddressSubunitNumber  | Billing Address Subunit
 billingAddressSuburb         | Billing Suburb
 billingAddressTitle          | Billing Address Title