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 Import (Moderator: Yashodha Chaku) »
  • Import activities linked to org rather than individual
Pages: [1]

Author Topic: Import activities linked to org rather than individual  (Read 2546 times)

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Import activities linked to org rather than individual
January 25, 2011, 07:40:14 pm
Hi,

I don't know if I'm missing something obvious, but I want to import activities and have them attached to an organisation, but it seems to default to attaching to individuals.   I have a field that matches the strict dedupe rule for orgs but I can't work out how to make the import use this instead of the contact matching fields defined in the strict dedupe rule for individuals.

Any ideas appreciated.

thanks,
Anthony.

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: Import activities linked to org rather than individual
January 25, 2011, 08:33:18 pm

i took a quick look at the code and it seems like the match to Individuals is hard coded

you can potentially use Contact ID column and just give the org's contact 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

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Import activities linked to org rather than individual
January 25, 2011, 10:38:17 pm
Hi Lobo,

Yeah that's what I found out when I looked at CRM/Activity/Import/Parser/Activity.php that is it only supports importing activities and linking to contacts.  Should this be documented somewhere?  I'm not quite sure where it should go.

I thought about doing my own datasource and modifying it, but I think I'm going to use a version of what you did elsewhere and just script my own import.  It's a bit brute force but time constraints require the use of force at times :)

Thanks,
Anthony.

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: Import activities linked to org rather than individual
January 26, 2011, 08:25:10 am

i wrote a custom activity import script for a school auction project i'm working on. Its pretty hackish and hard coded:

http://svn.civicrm.org/sfschool/branches/v3.2/sql/parseAuctions.php

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

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Import activities linked to org rather than individual
January 26, 2011, 02:06:00 pm
Hi Lobo,

Yeah thanks, I was using something for what must have been the same project for you (importing student and household records) as a base.  One question I have for my understanding... is there a reason you build up your query to insert an activity rather than using the API call civicrm_activity_create?

Regards,
Malks.

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: Import activities linked to org rather than individual
January 26, 2011, 04:57:07 pm

This was a quick one off hack to import an excel spreadsheet. was much faster for me to write straight to the db tables in this case. i was not sure if the activity api dealt with custom fields

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Import activities linked to org rather than individual
January 27, 2011, 12:01:59 pm
Hi,

The activity api does allow you to add to custom fields - in fact it is one of two apis for which there is a test

However, the format in the (v2) test is pretty non-standard - not sure if it also supports the standard format for custom fields ($params['custom_12']= 'custom data')


        //  Create an activity with custom data
        $params = array(
                'source_contact_id'   => 17,
                'subject'             => 'Discussion on Apis for v2',
                'activity_date_time'  => date('Ymd'),
                'duration'            => 120,
                'location'            => 'Pensulvania',
                'details'             => 'a test activity',
                'status_id'           => 1,
                'activity_name'       => 'Test activity type',
                'custom'              => array( array(
                 array( 'value' => 'bite my test data',
                        'type'  => 'String',
                        'custom_field_id' => 11,
                        'custom_group_id' => 9,
                        'table_name'      => 'civicrm_value_activity_custom_9',
                        'column_name'     => 'activity_custom_11',
                        'is_multiple'     => 0,
                        'file_id'         => null
                        ) ) )
                        );
        $result = civicrm_activity_create( $params );
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Import activities linked to org rather than individual
January 30, 2011, 11:37:11 pm
Hey,

Thanks for links and background on these.  I ended up writing a Drupal module to do the import... it's reasonably configurable with an array at the start and can do multiple imports, and uses Drupal's batch API to avoid server timeouts etc.  Is there any worth in putting it someplace?  It's rough but might serve as an example?

Malks.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Import activities linked to org rather than individual
January 31, 2011, 02:01:15 am
Hi,

Sure, publish it somewhere (eg. github).

For eileen, yerk, another thing to put back in shape or at least test with custom_xxx. (now on contacts, seems to be custom_xx_yy)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Import activities linked to org rather than individual
January 31, 2011, 02:05:27 am
I think

    public static function getKeyID($key, $all = false)

extracts the 2 parts  - but I don't speak regex so can't scan & check
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Import activities linked to org rather than individual
January 31, 2011, 04:09:51 am
Quote from: Eileen on January 31, 2011, 02:05:27 am
but I don't speak regex so can't scan & check

You should learn it, that's a wonderful tool to create wonderfully complicated to debug problems ;)

X+

-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) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Import activities linked to org rather than individual

This forum was archived on 2017-11-26.