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 Organisation subtype record without losing custom data
Pages: [1]

Author Topic: Changing Organisation subtype record without losing custom data  (Read 1577 times)

alanski

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 5
  • Cup of tea? Yes please
    • Joomkit
  • CiviCRM version: Version in post
  • CMS version: Joomla
  • MySQL version: 5.0
Changing Organisation subtype record without losing custom data
April 17, 2012, 11:59:35 am
I have Org records that for membership sign up reasons [see:http://issues.civicrm.org/jira/browse/CRM-9586] need their subtype reverting to standard Organizational record.

I can find my way around the SQL for the most part but is it possible or is the custom data somehow specific to the subtype name/id? I can't see yet that this is the case but am asking here before I butcher the db :)

alanski

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 5
  • Cup of tea? Yes please
    • Joomkit
  • CiviCRM version: Version in post
  • CMS version: Joomla
  • MySQL version: 5.0
Re: Changing Organisation subtype record without losing custom data
April 17, 2012, 02:27:18 pm
Re-reading this its not that the issue tracker issue above is the issue.
I think it is that on behalf settings in membership/contribution pages are not willing to show custom fields associated with the sub type - they will only show custom fields for Organisation default types, not their sub types

So my question is how to revert a sub types without data loss or a better solution...
how to get membership/contribute profile on behlalf of to show extra fields for Organisation sub types?
[Should add CiviCRM 4.11 J2.5.x]
« Last Edit: April 17, 2012, 02:34:21 pm by alanski »

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Re: Changing Organisation subtype record without losing custom data
April 18, 2012, 06:57:17 am
Were you able to batch update the org sub-type from the general org to a more specific one without loosing custom data or did they always have the subtype?  Reason I ask is cause I am trying to do exact the opposite of what you are doing with batch update and a profile with one field where that field is the sub-type so I can move general orgs down into more specific ones.  I just don't see the field value to be able to set this. Sub-Type doesn't display anything for me in the drop-down list. I'm also using 4.1.1  -thanks
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Re: Changing Organisation subtype record without losing custom data
April 18, 2012, 07:16:52 am
Lobo - Just replied to my post about this.  Apparently, batch update explicitly omits the contact type field from being changed as it implies potential loss of data.  Guess the only way would be to export and then import again which at that point you could change the contact type directly.
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

alanski

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 5
  • Cup of tea? Yes please
    • Joomkit
  • CiviCRM version: Version in post
  • CMS version: Joomla
  • MySQL version: 5.0
Re: Changing Organisation subtype record without losing custom data
April 18, 2012, 08:31:44 am
Actually have had success doing this with two SQL queries. I am checking results now. I think it will be more complicated round the other way

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Re: Changing Organisation subtype record without losing custom data
April 18, 2012, 09:52:05 am
Is the contact type field value only stored in one location?  If so could you tell me what table and field you are modifying in your SQL queries to make this a quick job, or cleanse and post SQL code here as I have tons I need to do after restructuring some data to better align with membership management profiles.  Thanks.
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

alanski

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 5
  • Cup of tea? Yes please
    • Joomkit
  • CiviCRM version: Version in post
  • CMS version: Joomla
  • MySQL version: 5.0
Re: Changing Organisation subtype record without losing custom data
April 18, 2012, 10:21:04 am
Hiya,
Here is my SQL.
We had subtype of schools - i wanted to keep the custom fields mapped to schools subtype. So far I have found that below seemed to be the key. Your scenario is the reverse though as I understand it.

UPDATE `xxx`.`civicrm_contact` SET `contact_sub_type` = NULL WHERE `civicrm_contact`.`contact_sub_type` = "School";

UPDATE `xxx`.`civicrm_custom_group` SET `extends_entity_column_value` = NULL WHERE `extends_entity_column_value` = "School";

So off top of my head you would need something like:

UPDATE `xxx`.`civicrm_contact` SET `contact_sub_type` = "MYSUBTYPE" WHERE `civicrm_contact`.`contact_sub_type` = NULL;

UPDATE `xxx`.`civicrm_custom_group` SET `extends_entity_column_value` = "MYSUBTYPE" WHERE `extends_entity_column_value` = NULL;

No idea if this woul dwork and damage is huge so backup everything 3 times before changing anything :)

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 Organisation subtype record without losing custom data
April 18, 2012, 11:13:37 am

also ensure u do:

truncate civicrm_cache

after u run that set of sql

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Changing Organisation subtype record without losing custom data

This forum was archived on 2017-11-26.