I want to add custom fields to mail templates without writing tokens. Is this possible?

If so, where can I find the entity relationship diagram for civi? Thanks,

  • 2
    Are these custom fields associated with something other than contacts, e.g. contributions, membership? If they are on contacts, then the custom fields are on the list of tokens.
    – Paul-Tahoe
    Mar 31 '15 at 22:12
  • Paul-Tahoe - I think your "comment" could rightfully be considered an "answer" here - and the correct one, at that! Apr 1 '15 at 0:26
  • Just curious - why did you want to 'find the entity relationship diagram' to answer this question? Apr 1 '15 at 8:20
  • The entity diagram is how I've found the mapping of database tables, relations and fields. Is there another way for me to determine field names? Apr 1 '15 at 23:17
  • With regard to contacts, yes, I know about the tokens. I want to be able to include membership, relationship, contribution fields in my messages. For example, the representative for an organization and the organization's contributions in December. Event registration communications with the org registering and its designated contact. There are so many needs we have for crossing civi modules. Apr 2 '15 at 0:09

Yes it is possible to include custom contact fields for individuals in messages sent by CiviMail by just selecting the custom field from the list of tokens.

The help on the Insert Token widget for CiviMail explains how to do it for custom organizational contacts, and the same process works for custom household fields as well:

Custom tokens (based on custom data) can be added for organizations as well. These tokens will not be displayed in the list of available tokens, but can be added manually. The format is {contact.custom_12} – where 12 is the ID of the custom data field. To find the custom data field ID, go Administer > Customize Data & Screens > Custom Fields and click ‘edit’ on the field you want to use. Look at the URL. The last part of the URL will be an equal sign and a number (=12). The number (12 in this example) is the id of that custom field.

  • Note that this process only works for custom fields on contacts, not on things like memberships or participant records.
    – Joe Murray
    Apr 4 '15 at 19:54
  • Worked like a charm for a single field. Is there a way to specify a field within a custom group? Apr 4 '15 at 20:44
  • Can you clarify, as all custom fields are in groups of custom fields that appear in the browser as fieldsets? Custom fields on individual contacts can be inserted using the widget for toens just above and to right of the message body in the CiviMail editor page. The custom fileds have a double colon in their name, and after it the name of the custom group that they are a part of. Alternatively, you can use the quoted instructions to insert custom fields for Individual contacts too. But I have the sense you mean something else...
    – Joe Murray
    Apr 6 '15 at 2:04
  • I'm sorry to have taken your time on this. What I was referring to were fields with multiple checkboxes, such as volunteer availability. But I can think of other ways to deal with this. Apr 7 '15 at 14:34

I have custom data fields, and they are 'multi-value' sets (e.g. employment history; John has 3 prior jobs attached to his contact profile.) These data elements are not currently available by default in CiviCRM. In order for me to be able to use these custom data elements in CiviMail, I had to write a bit of code in a Drupal Module to implement the proper 'hooks' as described at http://wiki.civicrm.org/confluence/display/CRMDOC/Customized+%28and+Custom%29+Tokens See my code at http://pastebin.com/LaDq0z82


I have just created a number of custom tokens for things like relationships, mailing lists and some multi-value custom fields. I used hooks to do so, and found the API explorer (Support -> Development -> API Explorer)very useful in the development as it helped create the key code to get the data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.