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) »
  • 1-click smart group csv export in drupal?
Pages: [1]

Author Topic: 1-click smart group csv export in drupal?  (Read 1077 times)

arielqgold

  • I’m new here
  • *
  • Posts: 17
  • Karma: 1
  • CiviCRM version: 3.3.1, 3.3.5, 3.4.5
  • CMS version: Drupal 6.22
1-click smart group csv export in drupal?
March 25, 2011, 03:13:26 pm
So the use case is that an organization has a smart group of all individuals and organizations with a complete mailling address, and they want a csv file to export and send to the printer/mailing house.

They have a saved export mapping, and do this regularly, so  I'd like to put somewhere in a nav block a link that they can click and it will prompt them to view/save the csv file for that smart group. How do folks recommend I do this in drupal?

php is okay, please just point me in the right direction or give an example. thanks!
« Last Edit: March 25, 2011, 03:58:12 pm by arielqgold »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: 1-click smart group csv export in drupal?
March 25, 2011, 05:05:08 pm
Definitely need to do this in a module which (very roughly) does the following:
- uses civicrm_contact_get api to retrieve all the contact ID's for your smart group
- retrieve the fields associated with your export map
- call functions from the Export BAO (CRM_Export_BAO_Export) - exportComponents does most of the work but you need to pass in the fields

Caveat - this is theoretical, might be some road-blocks. I do think it would be good to be able to do this, so if you hit issues jump on irc to discuss possible core improvements to make this possible.
Protect your investment in CiviCRM by  becoming a Member!

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: 1-click smart group csv export in drupal?
March 25, 2011, 09:45:43 pm

Am wondering if you could potentially accomplish this by scripting the whole "click process" via selenium or something similar. Recording the below in selenium is fairly easy, i have not made a selenium script (1-clickable), but suspect u can do that and avoid any significant programming :)

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: 1-click smart group csv export in drupal?
March 25, 2011, 11:10:10 pm
Hi,

If you can do it by shell (ie run it in the cron and mail the result)

bin/csv/export.php is a new php shell in 3.4 and basically is a wrapper to any get api call.

if you call it from civicrm_root

bin/csv/export.php -uuser -ppassword -sdefault Contact group=42 rowCount=10000 return=sort_name,email,phone > /tmp/your.csv should do it.

If you need different columns name, update the first line of the csv.

if you need a complex mapping that isn't handled by contact api, create your api/v3/Ariel.php that has your civicrm_api3_Ariel_get and voila.

We would like to implement the same thing from the web as /civicrm/api/csv?entity=Contact&group=42&return= for 3.4.1....  would you be interested to make it happen ?

X+

P.S. If you have loads of contacts, I would suggest to create a new bin/csv/bigexport.php
It would first call the api to have a count of contacts, then call the get api with the right params (rowCount and start if my memory is right)

P.S2 the export cli is pretty new and I've used it only to export tags and relationship and options, ie. small lists. YMMV and patch welcome
« Last Edit: March 25, 2011, 11:17:09 pm by xavier »
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • 1-click smart group csv export in drupal?

This forum was archived on 2017-11-26.