CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Joomla! Installations (Moderator: Deepak Srivastava) »
  • Error when using UK Counties *** Solved ***
Pages: [1]

Author Topic: Error when using UK Counties *** Solved ***  (Read 1071 times)

DamianBunn

  • Guest
Error when using UK Counties *** Solved ***
March 18, 2009, 07:25:24 am
I have created a script to import UK Counties into the civicrm_state_province table (attached) which works fine and I have amended the input fields so that county does not show, but the state province does.

You can select the UK county from the drop down list, however when I save I get an error:

DB Error: constraint violation

Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`britanni_trbcp/civicrm_address`, CONSTRAINT `FK_civicrm_address_state_province_id` FOREIGN KEY (`state_province_id`) REFERENCES `civicrm_state_province` (`id`) ON DELETE SET NULL), 1452

I also received the same error if I try to import from a CSV file.

Hopefully this is simple to resolve as this is the last thing I need to get done on CiviCRM before I can go live.

TIA

Damian
« Last Edit: March 18, 2009, 09:08:30 am by DamianBunn »

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Error when using UK Counties
March 18, 2009, 07:51:15 am
Hi,

Hard to know without having your modified templates/code visible, but I'd suspect that you have to "hardcode" the country to uk instead of leaving it empty.

Out of curiousity, why don't you leave uk as the only country and the default one ?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

DamianBunn

  • Guest
Re: Error when using UK Counties
March 18, 2009, 08:43:27 am
Xavier - thanks for getting back to me.

The UK is not hard coded and the default is set United Kingdom. If I can provide you with any further information that could help resolve the problem. I have not changed any templates this is a fairly standard base install of 2.2.0. The only things I have changed are the county and stat/province tables.

Damian

DamianBunn

  • Guest
Re: Error when using UK Counties
March 18, 2009, 09:08:15 am
I went to the original SQL script used when creating the databases and changed the top section of my own script to:

DROP TABLE IF EXISTS `civicrm_state_province`;

CREATE TABLE civicrm_state_province (


     id int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'State / Province ID',
     name varchar(64)    COMMENT 'Name of State / Province',
     abbreviation varchar(4)    COMMENT '2-4 Character Abbreviation of State / Province',
     country_id int unsigned NOT NULL   COMMENT 'ID of Country that State / Province belong'
,
    PRIMARY KEY ( id )
 
    ,     UNIQUE INDEX UI_name_country_id(
        name
      , country_id
  )
 
,     
     CONSTRAINT FK_civicrm_state_province_country_id FOREIGN KEY (country_id) REFERENCES civicrm_country(id)   
)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;

This worked fine....

Damian

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Joomla! Installations (Moderator: Deepak Srivastava) »
  • Error when using UK Counties *** Solved ***

This forum was archived on 2017-11-26.