1

I would like to take a set of custom fields in CiviCRM which are attached to one Contact type (Individual), and move them to be attached to another Contact type (Organization). The fields are similar, but they are not all identical.

What is the best way of handling this? Export the custom fields and clean up the CSV before importing into the newly created custom fields?

Tenz
  • 13
  • 3
  • Are you moving the fields themselves or the contents of individual custom fields A, B, and C into organization custom fields X, Y, and Z? If the latter, how will you identify which individual corresponds to which organization?Finally, are you looking for – Andie Hunt Dec 16 '14 at 20:36
  • Moving the contents. The individuals are "Employees of" Organizations, so I'm hoping to use the "Current Employer ID" to match Individuals to Organizations. – Tenz Dec 16 '14 at 23:37

1 Answers1

1

The most efficient way would be straight through SQL:

INSERT INTO civicrm_value_org_stuff
SELECT null as id, c.current_employer_id as entity_id, i.first_field as first_org_field, i.second_field as second_org_field ...
FROM civicrm_value_ind_stuff i
LEFT JOIN civicrm_contact c ON c.id = i.entity_id
LEFT JOIN civicrm_value_org_stuff o ON c.current_employer_id = o.entity_id
WHERE o.id is null AND c.current_employer_id is not null

You'll have to take care of situations where there's already information in the destination table, but otherwise this should work fine. The table names are obviously made up, but they'll begin with "civicrm_value..." and the field names should be clear from that.

Andie Hunt
  • 705
  • 3
  • 8