Answers.Body: <p>I've tried various ways of importing complex entities. At the end of the day, the best tip I have to offer you is to write a small program to create the entities via the api.</p>
  
  <p>You can either run it on the server (php) or run it over REST (php or my current favorite, node.js)</p>
  
  <p>I found it much easier to deal with edge cases, errors, weird matching logic...</p>
  
  <p>If you are on drupal, check Eileen work to integrate with the migration module</p>
  
  <p>If you are prepared to invest a significant amount of time learning kettle, amnesty spain has shared a module to make it easier to pull or push data from civicrm.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-08T17:23:28.420Z
Answers.Text: Hi Xavier - I agree, Kettle is how I handle this when I do my own migrations - but in this case I'm specifically looking for a way to let end users import activities that have multiple contacts.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-08T16:39:30.673Z
Answers.LastActivityDate: 2015-04-08T16:39:30.673Z
Answers.UserDisplayName: Xavier
Body: <p>Has anyone got tips for the best implementation for this that's friendly to a savvy end-user?  I can script it in an ETL tool, but that's not an option for them.</p>
  
  <ul>
  <li>"Import Activities", as best I can tell, will only import a single contact ID.</li>
  <li>You can import more contacts via the ActivityContact API (with API CSV GUI Import extension) but this is hard, because there's no good way to match the imported activity to the CSV you imported from.  Activities don't have an "external identifier" field.</li>
  </ul>
  
  <p>The only real choice I see is to hijack an field I'm not using like "Engagement Level" and use that as a temporary "external identifier" - but that's pretty ugly.</p>
  
  <p>Any other approaches short of building a custom import?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-01T17:32:31.543Z
Comments.Text: I've done a ton of importing of contacts and memberships.  Had never tried activities.  I just did and had no issues importing the exact same activity to several contacts.  I used a cvs file, one line for each contact and the Import Activities off the Contacts menu, which I assume is what you tried.  What kind of errors did you get?
Comments.UserDisplayName: Paul-Tahoe
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-01T20:13:54.273Z
Comments.Text: Hi Paul - I was trying to import one activity per row, not one contact per row.  I was hoping to specify multiple contact IDs per activity.  I like your approach - but is there a way to specify that two activities are the same besides by activity ID?  I'm trying to import activities that don't currently exist.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-01T23:13:12.610Z
Comments.Text: Ah yes. I see.  I tried a bunch of things with not much success.  What you'd want is for the record to try to match to some activity, if it doesn't create it, if it does just create the record in civicrm_activity_contact table.  Even if you include a valid activity_id it didn't create additional records in activity_contact table in my testing.
  
  The structure of activity_contact table is simple.  One thing you could do is to import one row to create the activity and then add the rows manually for the others to the activity_contact table.  Not sure if you can give the user some way to do that.
Comments.UserDisplayName: Paul-Tahoe
Tags: <import><activities>
Title: How do I import an activity with multiple target contacts?
ThreadText: # How do I import an activity with multiple target contacts?
  
  (Asked by: username_0 on 2015-04-01)
  
  Has anyone got tips for the best implementation for this that's friendly to a savvy end-user? I can script it in an ETL tool, but that's not an option for them.
  
  * "Import Activities", as best I can tell, will only import a single contact ID.
  * You can import more contacts via the ActivityContact API (with API CSV GUI Import extension) but this is hard, because there's no good way to match the imported activity to the CSV you imported from. Activities don't have an "external identifier" field.
  
  The only real choice I see is to hijack an field I'm not using like "Engagement Level" and use that as a temporary "external identifier" - but that's pretty ugly.
  
  Any other approaches short of building a custom import?
  
  **Tags:** import, activities
  
  > **Comments:**
  > **username_1**: I've done a ton of importing of contacts and memberships.  Had never tried activities.  I just did and had no issues importing the exact same activity to several contacts.  I used a cvs file, one line for each contact and the Import Activities off the Contacts menu, which I assume is what you tried.  What kind of errors did you get?  
  > **username_0**: Hi Paul - I was trying to import one activity per row, not one contact per row.  I was hoping to specify multiple contact IDs per activity.  I like your approach - but is there a way to specify that two activities are the same besides by activity ID?  I'm trying to import activities that don't currently exist.  
  > **username_1**: Ah yes. I see.  I tried a bunch of things with not much success.  What you'd want is for the record to try to match to some activity, if it doesn't create it, if it does just create the record in civicrm_activity_contact table.  Even if you include a valid activity_id it didn't create additional records in activity_contact table in my testing.  The structure of activity_contact table is simple.  One thing you could do is to import one row to create the activity and then add the rows manually for the others to the activity_contact table.  Not sure if you can give the user some way to do that.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-04-08. Score: 1
  
  I've tried various ways of importing complex entities. At the end of the day, the best tip I have to offer you is to write a small program to create the entities via the api.
  
  You can either run it on the server (php) or run it over REST (php or my current favorite, node.js)
  
  I found it much easier to deal with edge cases, errors, weird matching logic...
  
  If you are on drupal, check Eileen work to integrate with the migration module
  
  If you are prepared to invest a significant amount of time learning kettle, amnesty spain has shared a module to make it easier to pull or push data from civicrm.
  
  > **Comments:**
  > **username_0**: Hi username_2 - I agree, Kettle is how I handle this when I do my own migrations - but in this case I'm specifically looking for a way to let end users import activities that have multiple contacts.  
  
  ---
  
  