我想在CiviCRM中获取一组附加到一个联系人类型(个人)的自定义字段,并将它们移动到另一个联系人类型(组织)。字段类似,但它们并不完全相同。
处理此问题的最佳方法是什么?导入自定义字段并清除CSV,然后导入新创建的自定义字段?
答案 0 :(得分:1)
最有效的方法是直接通过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
您必须处理目标表中已存在信息的情况,否则这应该可以正常工作。表名显然是由表组成的,但它们以" civicrm_value ..."开头。字段名称应该清楚。