About code snippets

The snippets provided here have been taken from larger code projects and will probably not run out of the box. Often configurations are included or other unknown objects will be accessed but the idea of the snippet should be clear.

Checking for missing custom contactfields

If you are about to just report the usage of customfields that do not exist the following snippet might be of help. It reads all used fields from a configuration array as it uses a mapping from some database columns to Maileon fields.


Creating custom contactfields if required

In this case we create a simple boolean custom field if not available.


Creating transaction types if not available

The idea behind this snippet is that you provide a transaction name and a transaction id in a configuration array. If the ID is not set, the script will search for a transaction with the given name. If that is not found, it will be set up using all the attributes which are also predefined in the configuration.