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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Changing Data Type of Custom Field
Pages: [1]

Author Topic: Changing Data Type of Custom Field  (Read 2220 times)

mhenning

  • Guest
Changing Data Type of Custom Field
April 05, 2010, 08:50:36 pm
Hi,

A previous developer set the "assistant phone number" custom field to an integer.  I would like to switch it to a Alphanumeric Text.  I know how to change the type of the field in the database, but I was wondering what else I needed to do/change for civicrm to accept the change.

Thanks,
Matt

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Changing Data Type of Custom Field
April 06, 2010, 07:10:15 am

1. change the value in civicrm_custom_field
2. change the column type in the value table
3. truncate civicrm_cache

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mhenning

  • Guest
Re: Changing Data Type of Custom Field
April 06, 2010, 10:14:52 am
Thanks lobo

armogirl

  • Guest
Re: Changing Data Type of Custom Field
July 11, 2011, 03:29:05 am
Hello,

I had the same problem, but I didnt understand what to do.
Can u explain me more?

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
L
July 11, 2011, 06:11:38 am
For every custom field you create, CiviCRM creates a field in the MySQL table civicrm_custom_field. You have to look up your field in that table and change the type there. You also need to find which table CiviCRM created for your custom set (check in civicrm_custom_group and the name will start with civicrm_value....) and change the type of the corresponding field in there. And finally you will have to do the SQL command 'truncate table civicrm_cache'.

Example: I have created a custom data set called 'Extra data' with a field "service number' (which I set to integer and now want to make alpha). If this is the only custom dat set, a table called civicrm_value_extra_data_1 with a field called 'service_number_1'. It will also have added a field called 'service_number' to the file civicrm_custom_field. For both fields, you have to change the type.

If this is abacadabra to you, don't try this! In that case, consider hiring someone with MySQL capabilities to do it for you? (unfortunately you do need some techical expertise every now and then for CiviCRM).
Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Changing Data Type of Custom Field

This forum was archived on 2017-11-26.