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 »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Changing Custom Field Types that Contain Data
Pages: [1]

Author Topic: Changing Custom Field Types that Contain Data  (Read 1048 times)

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Changing Custom Field Types that Contain Data
June 23, 2010, 08:24:15 pm
Hi, long before I was involved in a particular project, the users setup a group of Custom Data fields available only for for "Individuals".  Now, a couple years and 5000 rows of Custom Data later, they want those fields available to all Contacts, not just Individuals.  This is a retrofit of the existing data. 

Sure, I could manually make some changes in the MySQL and retrofit, but are there any negative ramifications to this approach this that I should think about?  Is exporting and reimporting the data a better solution?
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Changing Custom Field Types that Contain Data
June 24, 2010, 12:26:09 am
You will have to manually change it in DB. Another solution would be to export contact with current custom field value. Create new custom field for Contacts and import it again.

HTh
Kurund
Found this reply helpful? Support CiviCRM

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Changing Custom Field Types that Contain Data
June 24, 2010, 12:27:15 am
I don't see any -ve ramification as long as you know how to do it correctly.

And since you going from specific (individual) -to-> general (contact), where entity object (contact) remains same, it should work fine w/o any data loss (from UI level).
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Changing Custom Field Types that Contain Data
June 28, 2010, 01:57:08 pm
Thanks guys, almost there, not quite.  Here are the steps I used.

First, I made a full backup of my database.

Then, find all the Custom Data Groups by running this query on the database.

Code: [Select]
select id,name,title,extends,extends_entity_column_id as entitiy_id, extends_entity_column_value as entitity_value, table_name from civicrm_custom_group;
After I identified the Group I wanted to change, I simply ran an update query like so:
Code: [Select]
update civicrm_custom_group set extends='Contact' where id=1;
This had the effect of exposing the custom data field to Organization Contacts, but the data will not save to the database, in other words, I make a selection, click Save, and then it is not stored.

Just as an afterthought, I cleared out templates_c but that didn't help.

I'm sure there is another table somewhere that needs changing, but where?



Try CiviTeacher: the online video tutorial CiviCRM learning library.

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Changing Custom Field Types that Contain Data
July 11, 2010, 05:12:05 pm
Update:

I was unable to figure a way to make CiviCRM open this old custom data group to all Contacts, not just Individuals.

So I exported all the data from CiviCRM using Advanced Search and the CSV export feature.

Then I created a new custom data group (good for All Contacts), loaded in the existing field sets (nice feature Civi!) and then imported.

I had about 5800 rows of data, and CiviCRM choked (hung for about 15 minutes) on the last 50 records and did not update as complete.  This is unfortunate, but it appears that the import actually worked and imported all the data.



Try CiviTeacher: the online video tutorial CiviCRM learning library.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Changing Custom Field Types that Contain Data
July 12, 2010, 04:02:25 am
Hey stoob - if it t'was I, I would go via phpmyadmin, find  mydatabase.civicrm_custom_group

then edit the option I want to change from indiv to contact

and testing shows the data is saving fine - so not sure if that helps your case but for others who might come after us and are more comfortable in that tool
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Changing Custom Field Types that Contain Data
July 12, 2010, 10:13:39 am
That is the action I did take, and the data didn't save.  It would show under an Organization, I would select the option, click the Save button -- but the data didn't "stick".  Thanks anyway, the other approach didn't take too long (~1 hour).

UPDATE: I figured out it was a caching issue.  I cleared both templates_c directory, logged out, then cleared and my browser cache simultaneously, and then the above query worked.

« Last Edit: July 15, 2010, 10:24:49 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Changing Custom Field Types that Contain Data

This forum was archived on 2017-11-26.