cf(uid)
Function name | Description |
---|---|
cf(uid) | Returns a relation which lists all custom fields for the given UID. |
Parameter name | Description |
---|---|
uid | The UID (account or subscription ID) for which you wish to retrieve the custom fields. |
This function returns all custom fields for a given UID.
Note: Note that
cf(uid) returns a relation - that is, it works like an SQL table rather
than an SQL column. The cf(uid) function can therefore be used anywhere a table
might be used. This also means that you will see strange results if you try to use
cf(uid) as a column in a query.
To list all of the custom fields on an
account:SELECT * FROM cf(uid('2142420815')) ORDER BY custom_field;
custom_field | value
------------------+------------------
usn | 2142420815
companyName |
contactNameTitle | Mr
contactNameFamily | Keating
contactNameGiven | Paul
creationDate | 2012-05-07
Because cf(uid) is a relation, you can order the results any way you like:SELECT * FROM cf(uid('2142420815')) ORDER BY
custom_field;
custom_field | value
---------------------------+---------------------------
billingAddressCountry | Australia
billingAddressPostcode | 3546
billingAddressState | VIC
billingAddressStreetName | First
billingAddressStreetNumber | 33
You can join the results with any other table, including the custom_fields table:SELECT name, value FROM cf(uid('2142420815')) JOIN custom_fields ON (custom_fields.code
= custom_field);
name | value
----------------------+----------------------
Billing Country | Australia
Billing Postcode | 3546
Billing State | VIC
Billing Street Name | First
Billing Street Number | 33
Billing Street Type | ST
Billing Suburb | Wellville