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) »
  • Moving a "Custom Field" from one "Group of Custom Fields" to another
Pages: [1]

Author Topic: Moving a "Custom Field" from one "Group of Custom Fields" to another  (Read 2387 times)

chaos21in

  • Guest
Moving a "Custom Field" from one "Group of Custom Fields" to another
May 11, 2007, 10:01:26 pm
Hi,

I need to move one "Custom Field" created in civiCRM "Custom data" from one "Group of Custom Fields" to another. A simple solution is to delete it from one and recreate it in another, but mind that it is created long back and lot of data of individual users are saved using this custom data field, so i would like to avoid this delete-recreate method. Is there any other way round.

regards,
--rafi

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: Moving a "Custom Field" from one "Group of Custom Fields" to another
May 11, 2007, 11:06:30 pm

the easiest way to do this is by direct manipulation of the database. If you are not familiar with sql, you might want to find someone who can hep you. Please read and follow these steps carefully

1. backup your current civicrm database

2. find the current custom field id, lets call it FIELD_ID

3. find the new custom group id, lets call it GROUP_ID

4. run the following sql statement

update civicrm_custom_field set custom_group_id = GROUP_ID where id = FIELD_ID

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

chaos21in

  • Guest
Re: Moving a "Custom Field" from one "Group of Custom Fields" to another
May 12, 2007, 01:33:48 am
Hi,

Thanks it worked.

--rafi

Andrew Perry

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 1
  • Building empowering tools that comply with rules
    • Community Builders Australia
  • CiviCRM version: 3.x, 4.x
  • CMS version: Joomla 1.0.x, 1.5.x -> Drupal 6.x, 7.x, WordPress
  • MySQL version: 5.1, 5.5, 5.6
  • PHP version: 5.2, 5.3, 5.4
Re: Moving a "Custom Field" from one "Group of Custom Fields" to another
April 17, 2008, 08:04:31 pm
I just tried this but found that it doesn't work - probably due to 2.0 schema changes.

Are you able to provide an update here?
Community Builders Australia Pty Ltd
www.communitybuilders.com.au

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: Moving a "Custom Field" from one "Group of Custom Fields" to another
April 17, 2008, 10:26:19 pm

In 2.0 this is a wee bit more complicated than a single update statement (in addition to the update, you will need to alter two tables, the old and the new)

if you like, we can work on this during the training

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

Andrew Perry

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 1
  • Building empowering tools that comply with rules
    • Community Builders Australia
  • CiviCRM version: 3.x, 4.x
  • CMS version: Joomla 1.0.x, 1.5.x -> Drupal 6.x, 7.x, WordPress
  • MySQL version: 5.1, 5.5, 5.6
  • PHP version: 5.2, 5.3, 5.4
Re: Moving a "Custom Field" from one "Group of Custom Fields" to another
April 18, 2008, 01:04:52 am
haha - yes - thought that would be an appropriate response!  I also took a look and found the new style tables for each custom data group.
Community Builders Australia Pty Ltd
www.communitybuilders.com.au

gunzip

  • Guest
Re: Moving a "Custom Field" from one "Group of Custom Fields" to another
May 22, 2009, 02:35:39 am
i have the same need with 2.2. news on it ?

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Moving a "Custom Field" from one "Group of Custom Fields" to another
May 22, 2009, 03:49:28 am
For both 2.2 and 2.0, I would suggest creating the new field in the new custom group, copying the data across via SQL, then removing the old field.

We recently had some similar requirements, except we were moving data about a member's AP payment from the Contact record to the Membership record.

In that case, having created the custom field against memberships, we used the following SQL - I hope it will help you do something similar:

Code: [Select]
             CREATE TABLE test.ap_memberships
                   SELECT m.id
                     FROM custom_value_1_Other ap
                     JOIN civicrm_contact c ON ap.entity_id = c.id
                     JOIN civicrm_membership m ON m.contact_id = c.id
                    WHERE ap.Payment_Method = 'AP' ;

              INSERT INTO civicrm_value_1_ap_payment_pd_test_20 ( domain_id, entity_id, pays_ap )
                   SELECT 1, id, 'yes'
                     FROM test.ap_memberships
  ON DUPLICATE KEY UPDATE pays_ap='yes';

So Andrew - are you going to one of the US training workshops? Or have you got a special secret Aussie session happening soon? :)
@xurizaemon ● www.fuzion.co.nz

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: Moving a "Custom Field" from one "Group of Custom Fields" to another
May 22, 2009, 04:19:18 am
Chris - that was an April 08 discussion - I think you went to the training  :P
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

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Moving a "Custom Field" from one "Group of Custom Fields" to another
May 23, 2009, 12:46:16 am
Ha - good catch pete :)
@xurizaemon ● www.fuzion.co.nz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Moving a "Custom Field" from one "Group of Custom Fields" to another

This forum was archived on 2017-11-26.