When creating custom fields, and custom field groups, I have fallen into two pit falls.

First, the name of a custom field should not exceed a certain length, causing malfunction in the SQL structure.

Second, values should be unique. Of course, you would say, but look at this example: values: 1,2,3,4,5,6,7,8,9,10,11,12. When showing the values in a report, the 2 will show for both 2 and 12, and value 1 will show for 1,10,11 and 12.

The question is, what things should be considered when creating custom fields?


If you find yourself wanting to give really long custom field names, think about whether you really should have a fairly short label and then provide help text that goes along with the field.

Besides causing database problems (though CiviCRM largely handles that on its own by just cutting off the field name), you'll have trouble displaying a super-long field name on forms and in reports.

For values, are you actually experiencing this problem? If multiple choices are allowed in a field (let's say all those numbers are available as checkboxes), they're separated by a delimiter character in the database. Searching for 2 won't pull a contact with 12, and searching for 12 won't show results that have both 1 and 2.

In the field itself, the storage is like (not with an asterisk but an unprintable character) "*1*2*6*" for having 1, 2, and 6 checked. It's stored like "*11*12*" for having 11 and 12 checked. They're easily distinguished.

  • Yes I am experiencing this. If I make a multiple choice field, and later on making a report, selecting the option for value 2, I also get included in the result the options for 12
    – Flying
    Mar 25 '15 at 8:34
  • You definitely have a problem in your site. This isn't supposed to happen. Either there's an issue with your CiviCRM version or a site-specific problem. One thing to check is your character encoding: maybe your system isn't adding that delimiter character to the saved values or using it to parse them.
    – Andie Hunt
    Mar 25 '15 at 11:12
  • Agree, this is behaviour I have not experienced so strongly suspect there is a strange problem on your site. Have you checked the actual values in the option group related to the custom field? You can see them with 'Administer/System Settings/Option Groups' Mar 25 '15 at 14:02
  • @AndrewHunt and ErikH Do any of you know if there is a setting somewhere where I should set such a delimiter character for custom multiselect fields?
    – Flying
    Mar 26 '15 at 18:01
  • Try using a numeric list with a leading zero.... ala, 01, 02, 03, .... 09, 10, 11....
    – DaveD
    Nov 6 '15 at 21:00

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.