I've got a 5.8.2 install on Drupal 7.61. When I try to add a new Financial Type, from /civicrm/admin/financial/financialType?reset=1, and click Add Financial Type button, after I enter the info and hit Save, what I see in the GUI is that the spinner spins forever, never returning control to the user. The debug log shows (I've put some hard newlines in for readability):

[to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::exceptionHandler prefix=""
info="INSERT INTO civicrm_financial_account (name , contact_id , financial_account_type_id , account_type_code , description ,
is_header_account , is_deductible , is_tax , is_active , is_default )
VALUES ('New Fin Type' ,  1 ,  3 , 'INC' , 'New Fin Type descript' ,  0 ,  0 ,  0 ,  1 ,  0 )
[nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`drupals_uherocrm2`.`civicrm_financial_account`,
CONSTRAINT `FK_civicrm_financial_account_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL)]"]

What this seems to show is that it is trying to create a new Financial Account (which I don't really understand because I thought I was only creating a Fin Type), but the Account needs to be linked to an existing Contact, and it's using contact_id=1 as a generic default? But I don't have a Contact with this id=1 in my system.

Any clues what's going on here? The GUI for creating a Fin Type is simple and doesn't given any clues about being linked to a Fin Account, at least not at creation time. Thanks.

Edit: Here is a pastebin of part of my error log, including two examples (which should be equivalent and redundant) of the constraint violation, along with a whole bunch of other junk besides the backtrace, whose value I wasn't sure of, so it was safer to include it. I've edited the file a little to remove my real domain name, just for a little more anonymity. Hope this helps to clarify: https://paste.pound-python.org/raw/15EPAPfiKEuG7T3in945/

  • I've just realized I can add a contact with id=1 and see if that's a workaround, but would still like to understand these internals better.
    – Kotodharma
    Commented Dec 22, 2018 at 2:08
  • Hmm - this sounds like a bug. Could you edit your question to include the backtrace from your error log? This should be easy to fix if we have the backtrace. Commented Dec 23, 2018 at 13:33
  • Thanks @JonG-MegaphoneTech, I have done that.
    – Kotodharma
    Commented Dec 25, 2018 at 0:44

1 Answer 1


Looks like the Default organization contact is missing in your database. Try to resave the contact by navigating to CiviCRM >> Administrator >> Communications >> Organization Address and Contact Info

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.