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) »
  • change the type of a field
Pages: [1]

Author Topic: change the type of a field  (Read 509 times)

armogirl

  • Guest
change the type of a field
July 11, 2011, 04:04:05 am
Hi,

A previous developer set the "passport number" custom field to an integer.  I would like to switch it to a Alphanumeric Text.  I dont know how to change the type of the field,because it's not let me to change it from costum data. Can anyone help me?

Thanks

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: change the type of a field
July 11, 2011, 06:50:49 am
It is not possible to change the type of a custom field. It may be possible to do this directly in the database, but that's not recommended.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: change the type of a field
July 11, 2011, 07:21:52 am
From CiviCRM v3.4.3, we do allow to change html type  (not data type ) of some custom fields, related issue is here
http://issues.civicrm.org/jira/browse/CRM-8176

But I think u need to change data type of the custom field
You will need to do this manually
(Please take db backup before go further bellow)

#1: Find field name ( 'name' ) of your custom field in table 'civicrm_custom_field'
       Lets say  name = 'my_integer_field'
       Fire following query:
     
Code: [Select]
      UPDATE civicrm_custom_field SET data_type = 'String' WHERE name = 'my_integer_field'
     
#2: Find table name used to store your targeted custom field values, You will get this table name ( 'table_name' ) in table 'civicrm_custom_group'
      Say ur custom value table name is 'civicrm_value_my_custom_groupname'
      Find targeted column in table 'civicrm_value_my_custom_groupname', say targeted column name is 'my_integer_field_10'
      Fire following query:
     
Code: [Select]
     ALTER TABLE  civicrm_value_my_custom_groupname CHANGE  my_integer_field_10 my_integer_field_10 varchar(255);
     
#3: Fire following query to clear contact field related cached data
     
Code: [Select]
    DELETE FROM civicrm_cache WHERE group_name = 'contact fields'
   
# logout, login and check

Rajan

armogirl

  • Guest
Re: change the type of a field
July 21, 2011, 12:50:47 am
thank u so much :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • change the type of a field

This forum was archived on 2017-11-26.