5

I am prototyping and testing import from M$ Access. Up to now I could quite easily import relationships, but I am missing the way to import also the relationship core Start date and custom fields I created in some relationship types. It seems like contact import is not prepared for this, right? So the only other way would be writing custom import scripts using the API? Any hints or documentation are appreciated!

3

From what I can tell this functionality is not available in core imports, which allow relationships to be imported as a side function (e.g. when importing contacts, you can specify relationships on the side).

There is an extension available called "CSV GUI Import to api" which allows more targeted imports, including one directly to Relationships.

CSV Import to relationship

I think you need to use Internal Contact IDs (I tried to find how to do it with external IDs and couldn't manage it), as well as having other info specified:

Relationship import fields

In the screenshot above (from the second field matching step), "Year" is a custom field that I added to a certain relationship type, and which can be imported to in this way. You can see the core date fields are also available.

2

Laryn's answer is good. The other popular method is the command-line CSV import tool: https://civicrm.org/blog/jamie/the-new-and-improved-cliphp-now-a-new-way-to-interact-with-api-v3

If you had a file that looked like this:

contact_id_a,contact_id_b,relationship_type_id,custom_34
4,8,2,1997
5,12,2,2008
etc.

You could import it with:

php /path/to/civiroot/bin/csv/import.php -e Relationship --file /path/to/your.csv

  • I am already beyond this stage but it could still be helpful in the future. I prefer this one because no extension is needed and it runs from the command line. – ñull Nov 29 '17 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.