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) »
  • Exporting custom data
Pages: [1]

Author Topic: Exporting custom data  (Read 1242 times)

dragontree

  • Guest
Exporting custom data
October 27, 2010, 02:19:47 am
I have a custom field (advselectbox) which uses organization names for labels and IDs for values.

When I export contacts, then the IDs are exported. What do I have to do so the IDs are changed to org names before creating the csv?
I figured it would be in the CRM/Export/BAO/Export.php file, is it true?

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Exporting custom data
October 30, 2010, 05:24:07 am
It's better not to modify core code if possible - you should try newly introduced hook_civicrm_export (http://wiki.civicrm.org/confluence/display/CRMDOC32/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmexport).

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

dragontree

  • Guest
Re: Exporting custom data
October 30, 2010, 08:27:39 am
I cant use that hook because i'm still using version 3.1.4 and I cannot upgrade at this time.

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Exporting custom data
October 30, 2010, 09:45:50 am
Ok than - take a look at commits for export hook implementation (http://issues.civicrm.org/jira/browse/CRM-6898?page=com.atlassian.jira.ext.fisheye%3Afisheye-issuepanel) - it should give you hints about where to plug with your modification. Remember to use Custom PHP path for your mods.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

dragontree

  • Guest
Re: Exporting custom data
November 02, 2010, 02:04:58 am
Thank you for your help.

I added the export hook and now its working fine.

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Exporting custom data
November 02, 2010, 05:40:02 am
Would you like to share your solution with others? It's quite a useful modification, community would benefit from knowing how to do it.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

dragontree

  • Guest
Re: Exporting custom data
November 02, 2010, 05:51:02 am
I just added the hook call to the export.php file just before creating the csv file:
Code: [Select]
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::export( $headerRows, $componentDetails, $exportMode );

added the export function to the utils.php:
Code: [Select]
    static function export(&$headerRows, &$componentDetails, &$exportMode) {
        $config = CRM_Core_Config::singleton( );
        require_once( str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php' );
        $null = & CRM_Core_DAO::$_nullObject;
        return
        eval('return ' .
                $config->userHookClass .
                '::invoke( 4, $headerRows, $componentDetails, $exportMode, $null, $null, \'civicrm_export\' );');
    }

and then i was able to use the hook.

I only needed to change some values (ids to names) in the data and that seems to be enough.

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Exporting custom data
November 02, 2010, 09:24:17 am
Sweet, thanks for sharing. :-)

m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Exporting custom data

This forum was archived on 2017-11-26.