0

Having an issue where I'm trying to import a series of CSV files into the Civi Contact Database. There were new custom fields created to do the import, but when I do the import with all the fields, I get an 'DB Error: constraint violation' error. If I just import the fields that were originally there, I successfully import the CSV into the DB.

So I must have done something wrong with the custom fields I created yesterday. But what? What should I look for to make sure the import is successful?

  • Update: I found that the issue was the custom field for Institution Country. If I tell that not to import, the problem is gone. However, the client wants it, so I have to figure out why this is occurring. Is this because I have another country field set in the main / default contact set? – Adam Bell Feb 27 '16 at 20:03
0

I have found that in order for CiviCRM to accept the country field during an import you have to spell the country exactly as it is written in CiviCRM DB. For example you cannot import 'UK', but 'Great Britain' instead (not sure if I remember the values correctly, but this is the concept anyway).

If this is your case indeed, you will have to export the country list from CiviCRM and use it to populate the respective field in your csv file.

  • Right. The client actually had used USA instead of UNITED STATES (and it has to be capitalized) but even after changing that (it was actually the only country that was used in this file) the import still wouldn't work. Only way it did was to make a new Country field and instead of using the default country dropdown Civi provides, I created one on my own, using the exact same field names. Worked. Import successful. Very odd. – Adam Bell Feb 29 '16 at 5:19
0

Two things: * "DB Error: constraint violation" isn't enough information to troubleshoot. If you get an error like this, turn on debugging and backtrace: Administration menu > System Settings > Debugging and Error Handling. Posting the debug info and a backtrace greatly increases others' ability to help! * What you're describing is a known bug: See here. Unfortunately, no one who's affected this has stepped up yet with a fix, or funds for the core team to fix it.

To give the usual pitch: CiviCRM is free to use, but not free to write. If you're making part of your living from CiviCRM, please consider being part of the community of folks who either fixes bugs or pays people to fix bugs.

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.