Import multiple selections

CiviCRMYou may have an existing list of selections (e.g. Nationalities) in your current database, and you want to use it in CiviCRM. This article describes one possible approach.


Create the Custom Field

Start by creating your custom field.

  1. Go to Administer > Customize Data and Screens > Custom Fields.
  2. Create a new Custom Field set if needed.
  3. Add a Custom Field.
  4. In the Data and Input Field Type section, choose the Select option.
  5. In the Multiple Choice Options section, create a couple of entries.

 

phpMyAdmin

Now access your database using your preferred MySQL console (I'm using phpMyAdmin). It's a good idea to backup your database before using phpMyAdmin to make changes.

  1. Browse to the civicrm_option_group table.
  2. Note the id number of your recently created Option Group.
  3. Browse to the civicrm_option_value table.
  4. Here you will see the two entries that you made in the previous section.
  5. Create a .CSV spreadsheet of the values that you'd like to import. Include the following columns:
    1. option_group_id
    2. label
    3. value (this is the unique number in your current database).
    4. name
    5. weight (this is the sort order)
    6. is_active (presumably all value 1)
  6. Note that I find it simpler if I delete the first row column headers.
  7. Select the Import tab.
  8. Browse to your newly created .CSV file
  9. Uncheck the Enable foreign key checks checkbox.
  10. In the Column names field, enter your comma separated columns (e.g. option_group_id, label, value, name, weight, is_active).
  11. Click Go.

 

Thanks for visiting.