I want to bulk update the Employer field for the Individual contacts who have an active relationship of "employee of".

Even though we have many active employee relationships for individuals, the Employer field is blank.


You can do this directly in the database by running the following update query:

UPDATE civicrm_contact, (civicrm_relationship r LEFT JOIN civicrm_contact c ON c.id = r.contact_id_a) LEFT JOIN civicrm_contact c1 ON c1.id = r.contact_id_b SET c.employer_id = r.contact_id_b, c.organization_name = c1.organization_name WHERE r.relationship_type_id = 5 AND c.contact_type = 'individual' AND c.employer_id IS NULL AND r.is_active = 1

This will update the employer field for all individual contacts who have an active employee relationship and do not have an employer already set.

| improve this answer | |

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.