6

I've got about 80 records in my database for contacts who all work for an important organisation that we liaise with. They've just changed their email domain, but all of the front part of their email addresses don't change, e.g. bob@old-domain.org is now bob@new-domain.org.

What's the simplest way to update all 80 addresses in CiviCRM?

7

Run a sql query on mysql table

UPDATE civicrm_email
SET email = REPLACE(email, '@old-domain.org', '@new-domain.org')
WHERE email LIKE '%@old-domain.org';
1
  • That's really helpful, as I struggle with MySQL syntax. This sort of functionality would be great to have in the UI.
    – Graham
    Jun 8 at 12:12
4

You can do a contact search for contacts with that email adress ending, and then bulk update with profile. And then manually copy/paste the correct ending on all 80 emails, before saving.

It takes more time than the SQL, but on the other hand you do it in the UI and have full control of the result without having to do extensive testing (which you should do when using SQL-commands pasted from online)

1
  • This is in fact what I ended up doing. With not many contacts involved it was workable. Clunky, but workable.
    – Graham
    Jun 10 at 8:11
3

You could export the above 80 with their Contact ID, then do a find/replace in a s/sheet, then reimport them using 'update' and match on Contact ID

(hmm having written this i now wonder if it would overwrite the existing email address or just add another one. will leave this here for now but delete if someone points out i am wrong)

As Alan says below "Using civicrm.org/extensions/api-csv-import-gui [you can work] directly with the email entities"

3
  • This would also require same amount of testing as the SQL solution
    – Flying
    Jun 8 at 20:06
  • I think for a non-technical user this has a lower threshold for usage than the SQL hence putting it up as an option.
    – petednz - fuzion
    Jun 9 at 0:34
  • 1
    I like this one the best! Using civicrm.org/extensions/api-csv-import-gui and working directly with the email entities would make this process a bit more bulletproof.
    – Alan Dixon
    Jun 9 at 14:22

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.